我使用reportviewer 进行渲染和扩展,但是这些代码使用旧文件扩展名进行扩展。例如,我想用 .xlsx 创建,但它创建 xls。如何更改默认 mimeType?
protected void ExportExcel_Click(object sender, EventArgs e)
{
Warning[] warnings;
string[] streamids;
string mimeType;
string encoding;
string extension;
string filename;
byte[] bytes = ReportViewer1.LocalReport.Render(
"Excel", null, out mimeType, out encoding,
out extension,
out streamids, out warnings);
filename = string.Format("{0}.{1}", "ExportToExcel", "xls");
Response.ClearHeaders();
Response.Clear();
Response.AddHeader("Content-Disposition", "attachment;filename=" + filename);
Response.ContentType = mimeType;
Response.BinaryWrite(bytes);
Response.Flush();
Response.End();
}