问一个ASP将数据导出Excel表格的问题???请用过这功能的富翁们帮帮忙,谢谢!!(20分)

T

tobey

Unregistered / Unconfirmed
GUEST, unregistred user!
代码如下:
...
dim ExcelApp
Set ExcelApp = CreateObject("Excel.Application")
...
可每每程序运行到这里时就出错,提示:没有权限: 'CreateObject'
为什么呢,我在网上找的资料都是这样调用的,可用在我机器上就出错呢??
请用过这功能的富翁们帮帮忙,谢谢!!
 
我用 com +导
<!-- #include file=&quot;Include/conStr.asp&quot
-->
<%

dim objUser,iRec,ExcelFileName,sErr,ReportType,ClassID,ExamID,GradeGroupID
ReportType=request(&quot;ReportType&quot;)
set objUser=Server.CreateObject(&quot;user.PRIVILAGE&quot;)
IF ReportType<30 THEN '年级前n名
iRec=objUser.Export_Excel(ConStr,Session(&quot;userID&quot;),ReportType,ExcelFileName,serr)
end if

if ReportType=30 then '//学生info
if isEmpty(request(&quot;ClassID&quot;)) then
response.Redirect(&quot;Error_Close.asp?sErr=必须选择班级...&URL=javascript:window.close();&quot;)
response.End()
end if

ClassID=request(&quot;ClassID&quot;)

iRec=objUser.Export_Excel_StudentInfo(ConStr,Session(&quot;userID&quot;),0,CSTR(CLASSID),ExcelFileName,serr)
END IF

IF ReportType=32 THEN '学生成绩
if isEmpty(request(&quot;ClassID&quot;)) then
response.Redirect(&quot;Error_Close.asp?sErr=必须选择班级...&URL=javascript:window.close();&quot;)
response.End()
end if
ClassID=request(&quot;ClassID&quot;)
ExamID=request(&quot;ExamID&quot;)
iRec=objUser.Export_Excel_Same_Interface(ConStr,Session(&quot;userID&quot;),ReportType,&quot;&quot;,ExcelFileName,serr,0,ClassID,ExamID)
END IF

IF ReportType=35 THEN
GradeGroupID=request(&quot;GradeGroupID&quot;)
ExamID=request(&quot;ExamID&quot;)
iRec=objUser.Export_Excel_Same_Interface(ConStr,Session(&quot;userID&quot;),&quot;35&quot;,&quot;&quot;,ExcelFileName,serr,GradeGroupID,&quot;0&quot;,ExamID)
END IF

IF ReportType=36 THEN
GradeGroupID=request(&quot;GradeGroupID&quot;)
ExamID=request(&quot;ExamID&quot;)
iRec=objUser.Export_Excel_Same_Interface(ConStr,Session(&quot;userID&quot;),ReportType,&quot;&quot;,ExcelFileName,serr,GradeGroupID,&quot;0&quot;,ExamID)
END IF

IF ReportType=40 THEN '年级前n名
GradeGroupID=request(&quot;GradeGroupID&quot;)
ExamID=request(&quot;ExamID&quot;)
iRec=objUser.Export_Excel_Same_Interface(ConStr,Session(&quot;userID&quot;),ReportType,&quot;&quot;,ExcelFileName,serr,GradeGroupID,&quot;0&quot;,ExamID)
END IF

IF ReportType=45 THEN '年级前n名
GradeGroupID=request(&quot;GradeGroupID&quot;)
ExamID=request(&quot;ExamID&quot;)
iRec=objUser.Export_Excel_Same_Interface(ConStr,Session(&quot;userID&quot;),ReportType,&quot;&quot;,ExcelFileName,serr,GradeGroupID,&quot;0&quot;,ExamID)
END IF
IF ReportType=46 THEN '年级前n名
GradeGroupID=request(&quot;GradeGroupID&quot;)
ExamID=request(&quot;ExamID&quot;)
iRec=objUser.Export_Excel_Same_Interface(ConStr,Session(&quot;userID&quot;),ReportType,&quot;&quot;,ExcelFileName,serr,GradeGroupID,&quot;0&quot;,ExamID)
END IF

IF ReportType=48 THEN '课程表
if isEmpty(request(&quot;ClassID&quot;)) then
response.Redirect(&quot;Error_Close.asp?sErr=必须选择班级...&URL=javascript:window.close();&quot;)
response.End()
end if
ClassID=request(&quot;ClassID&quot;)
iRec=objUser.Export_Excel_Same_Interface(ConStr,Session(&quot;userID&quot;),ReportType,&quot;&quot;,ExcelFileName,serr,0,ClassID,0)
END IF

set objUser=nothing

if iRec=0 then
response.Redirect(&quot;Error_Close.asp?sErr=&quot
& sErr & &quot;&URL=javascript:window.close();&quot;)
Response.End
end if
if iRec=-1 then
response.Redirect(&quot;Error_Close.asp?sErr=服务器发生异常错误,无法导出Excel...&URL=javascript:window.close();&quot;)
Response.End
end if

if ExcelFileName<>&quot;&quot
then Response.Redirect(&quot;Excel/&quot;& ExcelFileName)
Response.End()

%>


<SCRIPT language=javascript>
<!--
function MyOpenExcelWindow( url, winName, width, height)
{
xposition=0
yposition=0;
if ((parseInt(navigator.appVersion) >= 4 ))
{
xposition = (screen.width - width) / 2;
yposition = (screen.height - height) / 2;
}
theproperty= &quot;width=&quot
+ width + &quot;,&quot;+ &quot;height=&quot
+ height + &quot;,&quot;+ &quot;location=0,&quot;
+ &quot;menubar=1,&quot;
+ &quot;resizable=1,&quot;
+ &quot;scrollbars=0,&quot;
+ &quot;status=0,&quot;
+ &quot;titlebar=0,&quot;
+ &quot;toolbar=0,&quot;
+ &quot;hotkeys=0,&quot;
+ &quot;screenx=&quot
+ xposition + &quot;,&quot
//??êêó?óúNetscape
+ &quot;screeny=&quot
+ yposition + &quot;,&quot
//??êêó?óúNetscape
+ &quot;left=&quot
+ xposition + &quot;,&quot
//IE
+ &quot;top=&quot
+ yposition
//IE
window.open( url,winName,theproperty );
}



//window.open(&quot;Excel/<%=ExcelFileName%>&quot;);
MyOpenExcelWindow(&quot;Excel/<%=ExcelFileName%>&quot;,&quot;abc&quot;,800,400);
//alert('Excel/<%=ExcelFileName%>');
window.history.go(-1);
//-->
</SCRIPT>
 
有空来
www.51merit.com
坐坐
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
708
import
I
顶部