您的位置:首页 > 编程语言 > C#

C#导出Execl文件

2012-09-12 16:49 232 查看
#region 下载模版

protected void DownLoad_Click(object sender, ImageClickEventArgs e)

{

Response.ClearContent();

Response.ContentEncoding = System.Text.Encoding.UTF8;

Response.Charset = "UTF-8";

Response.ContentType = "application/ms-excel";

if (this.hid_PFLag.Value == "Talization")

{

Response.AppendHeader("Content-Disposition", "attachment;filename=Stencil.xlsx");

this.EnableViewState = false;

Response.BinaryWrite(File.ReadAllBytes(HttpContext.Current.Server.MapPath("../Execl/Stencil.xlsx")));

}

else if (this.hid_PFLag.Value == "GatherMst")

{

Response.AppendHeader("Content-Disposition", "attachment;filename=GatherMst.xlsx");

this.EnableViewState = false;

Response.BinaryWrite(File.ReadAllBytes(HttpContext.Current.Server.MapPath("../Execl/GatherMst.xlsx")));

}

else if (this.hid_PFLag.Value == "Pay")

{

Response.AppendHeader("Content-Disposition", "attachment;filename=Pay.xlsx");

this.EnableViewState = false;

Response.BinaryWrite(File.ReadAllBytes(HttpContext.Current.Server.MapPath("../Execl/Pay.xlsx")));

}

Response.End();

}

#endregion
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: