日期:2014-05-17 浏览次数:20457 次
protected void btnExport_Click(object sender, EventArgs e)
{
AsyncExportData Export = new AsyncExportData(this.ExportDataAsync);
AsyncCallback CallBack = new AsyncCallback(ExportCallBack);
HttpContext context=this.Context;
IAsyncResult IAResult = Export.BeginInvoke(context, CallBack, Export);
}
//异步导出
public delegate HSSFWorkbook AsyncExportData(HttpContext context);
public HSSFWorkbook ExportDataAsync(HttpContext context)
{
#region
//导出方法
#endregion
//写入到客户端
System.IO.MemoryStream ms = new System.IO.MemoryStream();
book.Write(ms);
try
{
context.Response.AppendHeader("Content-Disposition", string.Format("attachment; filename=" + System.Web.HttpUtility.UrlPathEncode("工单导出列表") + ".xls"));
context.Response.BinaryWrite(ms.ToArray());
}
catch
{
}
book = null;
ms.Close();
ms.Dispose();
return book;
#endregion
}
private void ExportCallBack(IAsyncResult Result)
{
AsyncExportData Exoprt = (AsyncExportData)Result.AsyncState;
HSSFWorkbook book = Exoprt.EndInvoke(Result);