我有一個這樣的簡單代碼。此代碼只是出口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