首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >为ReportViewer创建自定义导出到Excel (rdlc)

为ReportViewer创建自定义导出到Excel (rdlc)
EN

Stack Overflow用户
提问于 2010-08-16 22:20:39
回答 3查看 53K关注 0票数 19

我对在ReportViewer中为我的报告创建一个自定义的“导出到Excel”选项很感兴趣。这主要是因为我想要pdf disalbed,我通过:

代码语言:javascript
复制
 ReportViewer1.ShowExportControls = false;

因为在ReportViewer中无法禁用任何特定的导出功能(例如,pdf而不是excel)。下面是我(稍微)修改过的代码。理想情况下,我希望类似于以前的导出选项,我可以将文件保存到我想要的任何位置。

编辑:代码可以工作,但我需要如何修改文件流,以便提示用户可以保存到他们想要的任何位置,而不是让文件自动保存?

代码语言:javascript
复制
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();

}
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/3494009

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档