昨天遇到的问题.

使用ASP.NET调用COM组件来导出EXCEL文件.
需要得到的是一个带宏的EXCEL文件.
昨天写了一个测试的小例子.可是后来在SaveAs的时候就一直报错.

下面是我的代码,我从来没用过这样的方法导出EXCEL,代码写得不好,高手不要笑哦.

 1                Microsoft.Office.Interop.Excel.ApplicationClass tempExcel = null;
 2             
 3                 tempExcel = new Microsoft.Office.Interop.Excel.ApplicationClass();
 4                 tempExcel.Visible = false;

 5             //打开的是一个有宏的文件,做为模版
 6                 string strFileName = ActivePage.Request.PhysicalApplicationPath + @"DesktopModules\Common\CitiBankModule.xls";
 7                 bool boolTemp = false;
 8                 
 9                 Microsoft.Office.Interop.Excel.Workbook book = tempExcel.Workbooks.Open(strFileName,(object )boolTemp, System.Type.Missing, System.Type.Missing, System.Type.Missing, System.Type.Missing, System.Type.Missing, System.Type.Missing, System.Type.Missing, System.Type.Missing, System.Type.Missing, System.Type.Missing, System.Type.Missing, System.Type.Missing, System.Type.Missing);
10 //取得第三个Sheet
11                 Microsoft.Office.Interop.Excel.Worksheet sheettemp = (Microsoft.Office.Interop.Excel.Worksheet)book.Worksheets[2];
12                 sheettemp.Cells[11= "TEMP";
13                 //book.Saved = true;
14                 string strNewFileName = @"D:\EasySite4\" + DateTime.Now.Ticks.ToString() + ".xls";
//在下面这一部报错.
15                 book.SaveAs(strNewFileName, System.Type.Missing, System.Type.Missing, System.Type.Missing, System.Type.Missing, System.Type.Missing, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlNoChange , System.Type.Missing, System.Type.Missing, System.Type.Missing, System.Type.Missing, System.Type.Missing);
16                 //tempExcel.Save(strNewFileName);
17                 book.Saved = true;
18                 tempExcel.Visible = true;
19                 tempExcel.Quit();
20                 System.Runtime.InteropServices.Marshal.ReleaseComObject(book);   
21                 ActivePage.Response.Redirect(strNewFileName);


我使用的是VS2005,对操作COM组件一点都不熟.只是在以前学习VB的时候接触过.
我在网上搜了很多,最后还是不知道如何解决~~~
谢谢各位长老,请指点迷津~~~~~!

小妹将不胜感激~~~~~

我已经把磁盘的权限设置了.但是还是不行.
报的错是说
System.Runtime.InteropServices.COMException (0x800A03EC): Document not saved

是不是我的问题太菜了?所以没有人愿意理我啊???呃~~~~各位大哥,大姐帮帮我这只菜鸟吧~~~