【问题标题】:How to convert the report to an image? [closed]如何将报告转换为图像? [关闭]
【发布时间】:2012-12-10 09:36:52
【问题描述】:

我使用Report viewer 来显示我的报告。


现在我想将报告转换为图像。如何将 RDLC 报告转换为图像以供以后在其上绘制。

是否有任何库或方法可以做到这一点?

【问题讨论】:

    标签: c# asp.net .net image reporting-services


    【解决方案1】:

    您必须创建ReportViewer 的实例:

    ReportViewer report = new ReportViewer();
    

    根据您要创建的报告类型使用适当的属性设置它并传递它需要的所有参数,例如:

    report.ProcessingMode = ProcessingMode.Remote;
    report.ServerReport.ReportPath = reportPath;
    report.ServerReport.SetParameters(reportParameters);
    

    现在您可以要求ReportViewer 以您喜欢的格式呈现报告,它会返回给您一个字节数组,您可以简单地将其流式传输到客户端或保存在某处:

    byte[] reportContent = report.ServerReport.Render(reportFormat);
    

    reportFormat 是具有所需格式的string,例如要获得.TIF 图像,您必须要求"IMAGE" 格式,对于.PDF 文件,您必须要求"PDF" (有关其他支持的格式,请咨询 MSDN,它们取决于您使用的版本)。

    现在您可以简单地将reportContent 保存到文件中(或在响应中流式传输,添加适当的标头):

    System.IO.File.WriteAllBytes(path, reportContent);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-04
      • 2010-12-24
      • 2017-01-02
      • 2023-03-25
      • 2021-12-15
      • 1970-01-01
      • 2015-05-05
      • 1970-01-01
      相关资源
      最近更新 更多