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