【问题标题】:WPF : render report in PDF formatWPF:以 PDF 格式呈现报告
【发布时间】:2015-02-04 09:44:14
【问题描述】:

我正在使用 WPF rdlc,目前我正在使用 windowformhost reportviewer 来显示我的报告。如果我需要以 PDF 形式查看,我将通过单击导出按钮通过报表查看器导出为 PDF。

是否还是直接以 PDF 形式显示报告而不是执行上述所有步骤?

我使用VS2013作为开发工具

谢谢

【问题讨论】:

    标签: wpf rdlc wpf-4.0


    【解决方案1】:

    是的,这是可能的。您想首先使用 ReportViewer 呈现报表,然后将其流式传输到文件。写入文件后,您可以从文件系统打开 pdf。

    出口是这样的:

    byte[] renderedBytes = rptViewer.LocalReport.Render(
        "PDF",
        "<DeviceInfo><ExpandContent>True</ExpandContent></DeviceInfo>",
        out mimeType,
        out encoding,
        out fileNameExtension,
        out streams,
        out warnings);
    
    using (FileStream fsExport = new FileStream(@"C:\MyLocation\MyReport.pdf", FileMode.Create))
    {
        fsExport.Write(wordbytes, 0, wordbytes.Length);
    }
    

    现在您只需打开 pdf 文件:

    System.Diagnostics.Process.Start(@"C:\MyLocation\MyReport.pdf")
    

    【讨论】:

      猜你喜欢
      • 2018-12-18
      • 2023-03-18
      • 1970-01-01
      • 2011-12-20
      • 1970-01-01
      • 2010-10-22
      • 2010-09-29
      • 1970-01-01
      相关资源
      最近更新 更多