Asp.Net WebForm Rdlc 报表的使用之导出Excel
作者:互联网
实现代码
/// <summary>
/// 导出excel
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnExport_Click(object sender, EventArgs e)
{
//绑定数据
SetReportViewer();
// Variables
Warning[] warnings;
string[] streamIds;
string mimeType = string.Empty;
string encoding = string.Empty;
string extension = string.Empty;
byte[] bytes = _ReportViewer.LocalReport.Render("Excel", null, out mimeType, out encoding, out extension, out streamIds, out warnings);
// Now that you have all the bytes representing the PDF report, buffer it and send it to the client.
Response.Buffer = true;
Response.Clear();
Response.ContentType = mimeType;
String filename = HttpUtility.UrlEncode("报表导出", Encoding.UTF8);
Response.AddHeader("content-disposition", "attachment; filename=" + filename + "." + extension);
Response.BinaryWrite(bytes); // create the file
Response.Flush(); // send it to the client to download
}
标签:mimeType,Asp,string,Rdlc,Excel,filename,Response,Empty,out 来源: https://blog.csdn.net/liwan09/article/details/98741611