日期:2014-05-16 浏览次数:20574 次
public static void WriteResponseXls(string filePath, string targetFileName)
{
if (!String.IsNullOrEmpty(filePath))
{
HttpResponse response = HttpContext.Current.Response;
response.Clear();
response.Charset = "utf-8";
response.ContentType = "text/xls";
response.AddHeader("content-disposition", string.Format("attachment; filename={0}", targetFileName));
response.BinaryWrite(File.ReadAllBytes(filePath));
response.End();
}
}
this.ExportManager.ExportOrdersShippingToXls(filePath, orders);//执行方法
Page.ClientScript.RegisterStartupScript(Page.GetType(), "my2", "<script>alert('成功');</script>");
CommonHelper.WriteResponseXls(filePath, fileName);//下载Excel
Page.ClientScript.RegisterStartupScript(Page.GetType(), "my2", "<script>alert('成功');</script>");