我有兴趣在ReportViewer中为我的报告创建自定义导出到Excel选项。这主要是因为我想PDF disalbed而我做了通过:为ReportViewer创建自定义导出到Excel(rdlc)
ReportViewer1.ShowExportControls = false;
既然没有办法在的ReportViewer禁用任何特定的导出功能(例如PDF但不擅长)。这是我的(稍微)修改后的代码。理想情况下,我希望与之前的导出选项类似,可以将文件保存到我想要的任何位置。
编辑:代码的作品,但我将如何修改文件流,以便让文件不会自动保存我可以提示用户,以便他们可以保存到他们想要的位置?
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();
}
我搜索了这么久的答案。非常感谢你。 – 2014-04-24 13:12:01