1
1楼 unionapple1982 2007-01-31 17:35:06 代码如下: 有时候运行一点问题都没有 但是现在死活运行不起来 程序什么都没改 机器也重新启动过 还是不行,调试 执行倒 try语句之前就已经报错了 Dim oBooks As Excel.Workbooks, oBook As Excel.Workbook Dim oSheets As Excel.Sheets, oSheet As Excel.Worksheet Dim oCells As Excel.Range Dim sFile As String, sTemplate As String ' Instantiate the DataSet variable. 'Dim myDataSet = New DataSet ' Add the new DataTable to the DataSet. ' myDataSet.Tables.Add(myDataTable) Try sFile = Server.MapPath( "OTRecords.xls ") '定义模版文件 sTemplate = MapPath( "MyTemplate.xls ") oExcel.Visible = False oExcel.DisplayAlerts = False '定义一个新的工作簿 oBooks = oExcel.Workbooks oBooks.Open(MapPath( "MyTemplate.xls ")) oBook = oBooks.Item(1) oSheets = oBook.Worksheets oSheet = CType(oSheets.Item(1), Excel.Worksheet) '命名该sheet oSheet.Name = "First Sheet " oCells = oSheet.Cells '调用dumpdata过程,将数据导入到Excel中去 DumpData(dt, oCells) '保存 oSheet.SaveAs(sFile) oBook.Close() '退出Excel,并且释放调用的COM资源 oExcel.Quit() ReleaseComObject(oCells) : ReleaseComObject(oSheet) ReleaseComObject(oSheets) : ReleaseComObject(oBook) ReleaseComObject(oBooks) : ReleaseComObject(oExcel) oExcel = Nothing : oBooks = Nothing : oBook = Nothing oSheets = Nothing : oSheet = Nothing : oCells = Nothing System.GC.Collect() 'Dim url As String ' Dim Cpub As New HRMain.Pub 'url = Cpub.GetSystemURl(Myconnection, Session( "Project ")) Response.Redirect( "OTRecords.xls ") 2楼 goody9807 2007-01-31 18:20:31 http://www.cnblogs.com/goody9807/category/33971.html 3楼 zhongzhengfeng 2009-01-09 13:10:32 我也出现这个错误,
Server execution failed Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Runtime.InteropServices.COMException: Server execution failed Source Error: Line 561: Dim sTimes, eTimes As DateTime Line 562: sTimes = DateTime.Now Line 563: Dim oExcel As New Excel.Application Line 564: Dim oBooks As Excel.Workbooks, oBook As Excel.Workbook Line 565: Dim oSheets As Excel.Sheets, oSheet As Excel.Worksheet, oSheet1 As Excel.Worksheet Source File: C:\Inetpub\wwwroot\PDS\stdchart\stdchart_show.aspx.vb Line: 563 Stack Trace: [COMException (0x80080005): Server execution failed] pds.stdchart_show_aspx.genExcel() in C:\Inetpub\wwwroot\PDS\stdchart\stdchart_show.aspx.vb:563 pds.stdchart_show_aspx.Page_Load(Object sender, EventArgs e) in C:\Inetpub\wwwroot\PDS\stdchart\stdchart_show.aspx.vb:277 System.Web.UI.Control.OnLoad(EventArgs e) +67 System.Web.UI.Control.LoadRecursive() +35 System.Web.UI.Page.ProcessRequestMain() +750 你找到解决方法没有,我的是生成Excel的时候出错,但是刷新一下页面又可以了,这个错误是生成Excel的时候发生的,生成5次的话大概会有1次出现这个错
搜索墙@2009 www.pkwall.com all rights reserved QQ:276471788 [京ICP备09111534号]
声明:本站部分数据来源于网络,仅供参考,如有版权问题,请联系我们,我们将及时删除!转载本站请注明来源
| |||||