打开一个已有的EXCEL文件,并往里写入数据,却没有保存成功,同样的代码在自己机器上保存成功了,但在客户的服务器上却没有保存成功.代码如下:
Object oMissing = System.Reflection.Missing.Value; //实例化参数对象
oExcel = new Excel.Application(); //初始化Excel.Application对象
oBook = oExcel.Workbooks.Open(filename,oMissing,oMissing,oMissing,oMissing,oMissing,oMissing,oMissing, oMissing,oMissing,oMissing,oMissing, oMissing, oMissing, oMissing); //逐行写入数据,数组中前五行列标题,忽略,EXCEl中的行列号是从1开始
oExcel.Cells[1,1]="'一、";
.....
oBook.Saved = true;
oExcel.UserControl = false;
oBook.Save();
oExcel.Quit();
oMissing=null;
oBook=null;
oExcel=null;
GC.Collect ();
string destFileName=filename;
FileInfo fi=new FileInfo(destFileName);
Response.Clear();
Response.ClearHeaders();
Response.Buffer=false;
Response.ContentType="Application/x-msexcel";
Response.AppendHeader("Content-Disposition","attachment:filename="+Server.UrlEncode(Path.GetFileName(destFileName)));
Response.WriteFile(destFileName);
Response.Flush();
Response.End();请各位大虾帮帮忙,着急等呀
Object oMissing = System.Reflection.Missing.Value; //实例化参数对象
oExcel = new Excel.Application(); //初始化Excel.Application对象
oBook = oExcel.Workbooks.Open(filename,oMissing,oMissing,oMissing,oMissing,oMissing,oMissing,oMissing, oMissing,oMissing,oMissing,oMissing, oMissing, oMissing, oMissing); //逐行写入数据,数组中前五行列标题,忽略,EXCEl中的行列号是从1开始
oExcel.Cells[1,1]="'一、";
.....
oBook.Saved = true;
oExcel.UserControl = false;
oBook.Save();
oExcel.Quit();
oMissing=null;
oBook=null;
oExcel=null;
GC.Collect ();
string destFileName=filename;
FileInfo fi=new FileInfo(destFileName);
Response.Clear();
Response.ClearHeaders();
Response.Buffer=false;
Response.ContentType="Application/x-msexcel";
Response.AppendHeader("Content-Disposition","attachment:filename="+Server.UrlEncode(Path.GetFileName(destFileName)));
Response.WriteFile(destFileName);
Response.Flush();
Response.End();请各位大虾帮帮忙,着急等呀
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货