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");//

解决方案 »

  1.   

    我在程序调试的时候,一切运行正常的,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. &#8226; To make more memory available, close workbooks or programs you no longer need. &#8226; 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. &#8226; To make more memory available, close workbooks or programs you no longer need. &#8226; 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. &#8226; To make more memory available, close workbooks or programs you no longer need. &#8226; 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