如何将报告转换为图像?

Any*_*are 1 .net c# asp.net image reporting-services

我用它Report viewer来显示我的报告.


现在我想将报告转换为图像.如何将RDLC报告转换为稍后在其上绘制的图像.

有没有图书馆或方法可以做到这一点?

Adr*_*tti 7

你必须创建一个你的实例ReportViewer:

ReportViewer report = new ReportViewer();
Run Code Online (Sandbox Code Playgroud)

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

report.ProcessingMode = ProcessingMode.Remote;
report.ServerReport.ReportPath = reportPath;
report.ServerReport.SetParameters(reportParameters);
Run Code Online (Sandbox Code Playgroud)

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

byte[] reportContent = report.ServerReport.Render(reportFormat);
Run Code Online (Sandbox Code Playgroud)

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

现在您只需保存reportContent到文件(或在响应中流式传输,添加适当的标头):

System.IO.File.WriteAllBytes(path, reportContent);
Run Code Online (Sandbox Code Playgroud)