六、 附录
出错时Excel出现的死进程出现是一件很头疼的事情。在每个文件前加上“On Error Resume Next”将有助于改善这种情况,因为它会不管文件是否产生错误都坚持执行到“Application.Quit”,保证每次程序执行完不留下死进程。
补充两点:
1、其他Excel具体操作可以通过录制宏来解决。
2、服务器端打开SQL企业管理器也会产生问题。
复制代码 代码如下:
<%
OnErrorResumeNextstrAddr=Server.MapPath(".")setobjExcelApp=CreateObject("Excel.Application")
objExcelApp.DisplayAlerts=false
objExcelApp.Application.Visible=false
objExcelApp.WorkBooks.Open(strAddr&"\Templet\Null.xls")
setobjExcelBook=objExcelApp.ActiveWorkBook
setobjExcelSheets=objExcelBook.Worksheets
setobjExcelSheet=objExcelBook.Sheets(1)objExcelSheet.Range("B2:k2").Value=Array("Week1","Week2","Week3","Week4","Week5","Week6","Week7",
"Week8","Week9","Week10")
objExcelSheet.Range("B3:k3").Value=Array("67","87","5","9","7","45","45","54","54","10")
objExcelSheet.Range("B4:k4").Value=Array("10","10","8","27","33","37","50","54","10","10")
objExcelSheet.Range("B5:k5").Value=Array("23","3","86","64","60","18","5","1","36","80")
objExcelSheet.Cells(3,1).Value="InternetExplorer"
objExcelSheet.Cells(4,1).Value="Netscape"
objExcelSheet.Cells(5,1).Value="Other"objExcelSheet.Range("b2:k5").Select
objExcelApp.Charts.Add
objExcelApp.ActiveChart.ChartType=97
objExcelApp.ActiveChart.BarShape=3
objExcelApp.ActiveChart.HasTitle=True
objExcelApp.ActiveChart.ChartTitle.Text=
"Visitorslogforeachweekshowninbrowserspercentage"
objExcelApp.ActiveChart.SetSourceDataobjExcelSheet.Range("A1:k5"),1
objExcelApp.ActiveChart.Location1
'objExcelApp.ActiveChart.HasDataTable=True
'objExcelApp.ActiveChart.DataTable.ShowLegendKey=TrueobjExcelBook.
SaveAsstrAddr&"\Temp\Excel.xls"objExcelApp.Quit
setobjExcelApp=Nothing
%>
<!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.0Transitional//EN">
<HTML>
<HEAD>
<TITLE>NewDocument</TITLE>
<METANAME="Generator"CONTENT="MicrosoftFrontPage5.0">
<METANAME="Author"CONTENT="">
<METANAME="Keywords"CONTENT="">
<METANAME="Description"CONTENT="">
</HEAD>
<BODY>
</BODY>
</HTML>