搜索墙首页  编程技术  java  asp  ajax  php  c/c#/c++  数据库  oracle  mysql  db2  操作系统  windows  linux  股吧
首页 > 编程 > asp.net
 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次出现这个错
 1         
您的发言将按有关规定都会存档,您须为所发表后果负责,请您遵纪守法并注意语言文明。
标题:导出Excel报错 Server execution failed 很奇怪的问题 有时好有时又出错
热门关注
标题回复点击
Web.config文件里 <providerOption name="CompilerVersion" value="v3.5"/> 不允许有子节9569
100分 请教一问题,各位达人帮忙(帮顶给分)99474
js技巧收集(200多个) 看看看看!!!63438
准备离职了,我不知道怎么跟经理谈。大家给点意见吧?谢谢大家。62435
无法在此路径使用此配置节。当站点管理员使用继承的配置文件中的 <location allowOverride="false"> 锁定对此节的访问时会出现这种情况2415
【散分】Javascript 新年快乐(2),喜迎2010100408
请问大家"这是预编译工具生成的标记文件,不应被删除"的问题怎么解决?0395
链接服务器 "(null)" 的 OLE DB 访问接口 "Microsoft.Jet.OLEDB.4.0" 报错3383
ASP.NET热点问题解答14个61365
安装VS2005 出错 错误 1335,安装所需的 CAB 文件 XXX 已损坏?4362
搜索墙@2009 www.pkwall.com all rights reserved QQ:276471788 [京ICP备09111534号]
声明:本站部分数据来源于网络,仅供参考,如有版权问题,请联系我们,我们将及时删除!转载本站请注明来源