我有一个这样的简单代码。此代码只是出口gridwiev到excel文件..C#Excel 2007错误
Response.Clear();
Response.AddHeader("content-disposition", "attachment;filename=cat5.xls");
Response.ContentEncoding = System.Text.Encoding.GetEncoding("windows-1254");
//Response.ContentEncoding = System.Text.Encoding.UTF7;
Response.Charset = "windows-1254";
//Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
Response.ContentType = "application/vnd.ms-excel";
Response.Cache.SetCacheability(HttpCacheability.NoCache);
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
GridView1.RenderControl(htmlWrite);
Response.Write(stringWrite.ToString());
Response.End();
但是,我们公司的一些用户usign Excel 2003中,使用Excel 2007年,当我运行该代码的一些用户,是没有问题的Excel 2003中,但有一些问题在Excel 2007中像这样的图片。
我怎样才能解决这个问题?有没有人有想法?
最好的问候, Soner。
这是否发生在所有gridsizes?我从一些库中导出到Excel的问题,通过追加一些空行来获得上面的文件大小(我认为)7k来解决。 – 2010-12-22 09:04:05
我不计算网格大小的任何文件大小或什么?只需编写该代码并运行即可。我的问题是什么是不同的Excel 2003和Excel 2007 .. – 2010-12-22 09:26:22