当前位置:编程学习 > C#/ASP.NET >>

c# 建网页 从数据库里读数据生成excel文件 在客户端得到此excel文件(web page)得到

请问这个功能怎么实现, --------------------编程问答-------------------- Excel.Application oExcel; 
Excel.Workbook oBook; 
Object oMissing = System.Reflection.Missing.Value; 
oExcel = new Excel.Application(); 
oBook = oExcel.Workbooks.Add(oMissing); 
for (int i=1;i<=4;i++) 

oExcel.Cells[i,1]=i.ToString(); 
oExcel.Cells[i,2]="'bbb2"; 
oExcel.Cells[i,3]="'ccc3"; 
oExcel.Cells[i,4]="'aaa4"; 

oBook.Saved = true; 
oExcel.UserControl = false; 
string mm=Server.MapPath(".")+"\\aa.xls";//服务器保存地址 
oExcel.ActiveWorkbook.SaveCopyAs (mm); 
oExcel.Quit(); 
Response.Redirect ("aa.xls");// --------------------编程问答-------------------- 我在程序调试的时候,一切运行正常的,excel也可以正常download,可为什么网页访问的时候,出现这样的错误,不清楚是什么原因,我用的XP sp2  vs2005 :
Server Error in '/Web' Application.
--------------------------------------------------------------------------------

Microsoft Office Excel cannot open or save any more documents because there is not enough available memory or disk space. 

• To make more memory available, close workbooks or programs you no longer need. 

• To free disk space, delete files you no longer need from the disk you are saving to. 
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: Microsoft Office Excel cannot open or save any more documents because there is not enough available memory or disk space. 

• To make more memory available, close workbooks or programs you no longer need. 

• To free disk space, delete files you no longer need from the disk you are saving to.

Source Error: 


Line 234:        catch (Exception ex)
Line 235:        {
Line 236:            throw ex;
Line 237:        }
Line 238:    }
 

Source File: d:\Work\DotNet\Web\Default.aspx.cs    Line: 236 

Stack Trace: 


[COMException (0x800a03ec): Microsoft Office Excel cannot open or save any more documents because there is not enough available memory or disk space. 

• To make more memory available, close workbooks or programs you no longer need. 

• To free disk space, delete files you no longer need from the disk you are saving to.]
   _Default.Button2_Click(Object sender, EventArgs e) in d:\Work\DotNet\Web\Default.aspx.cs:236
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +107
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102

 


--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.42 --------------------编程问答-------------------- 我机器的磁盘空间和内存使用均没有问题。但是怎么系统提示磁盘空间或内存不足呢,奇怪。 --------------------编程问答-------------------- 问题已经解决了,谢谢 --------------------编程问答-------------------- 怎么解决的啊
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,