我对在ReportViewer中为我的报告创建一个自定义的“导出到Excel”选项很感兴趣。这主要是因为我想要pdf disalbed,我通过:
ReportViewer1.ShowExportControls = false;
因为在ReportViewer中无法禁用任何特定的导出功能(例如,pdf而不是excel)。下面是我(稍微)修改过的代码。理想情况下,我希望类似于以前的导出选项,我可以将文件保存到我想要的任何位置。
编辑:代码可以工作,但我需要如何修改文件流,以便提示用户可以保存到他们想要的任何位置,而不是让文件自动保存?
protected void btnExportExcel_Click(object sender, EventArgs e)
{
Warning[] warnings;
string[] streamids;
string mimeType;
string encoding;
string extension;
byte[] bytes = ReportViewer1.LocalReport.Render(
"Excel", null, out mimeType, out encoding,
out extension,
out streamids, out warnings);
FileStream fs = new FileStream(@"c:\output.xls",
FileMode.Create);
fs.Write(bytes, 0, bytes.Length);
fs.Close();
}
https://stackoverflow.com/questions/3494009
复制相似问题