1
我的頁面上有「Export To Excel」按鈕。 ButtonClick函數是將數據網格(dgrISGrid)導出爲excel代碼如下所示: 但執行其拋出錯誤時「線程被中止」。解決方法是什麼?導出爲Asp.Net中的優秀
protected void imgbtnExport_Click(object sender, ImageClickEventArgs e)
{
try
{
Response.Clear();
Response.AddHeader("content-disposition", "attachment;filename=InformationSystems.xls");
Response.Charset = "";
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentType = "application/vnd.xls";
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
dgrISGrid.RenderControl(htmlWrite);
Response.Write(stringWrite.ToString());
Response.End();
}
catch (Exception ex)
{
ExceptionHandler ObjExceptionHandler = new ExceptionHandler();
lblError.Text = ObjExceptionHandler.GetExceptionDetails(ex);
}
}
我試了一下。實際上messgaebox彈出要求打開或保存..之後,錯誤來了..說,裏面的文本是糾正。 其實我的應用程序有其他出口擅長..也沒有他們工作。是它的Excel版本問題我有>?它是我的電腦上的Microsoft Office Excel 2007 – 2010-12-10 07:11:09