如何转换为图像的报告? [英] How to convert the report to an image?
问题描述
我用报告查看器
来显示我的报告。
现在我想的报告转换为图像。如何能够在RDLC报告转换为图像后来它来画。
Now I want to convert the report to an image . How it possible to convert the RDLC report to an image to draw on it later .
有没有图书馆或方法来做到这一点?
Is there any library or method to do that ?
推荐答案
您必须创建的实例你的的ReportViewer
:
You have to create an instance of your ReportViewer
:
ReportViewer report = new ReportViewer();
设置它根据你要创建的报告类型适当性,并通过它需要的所有参数,例如:
Set up it with proper properties according to the report type you're about to create and passing all parameters it needs, for example:
report.ProcessingMode = ProcessingMode.Remote;
report.ServerReport.ReportPath = reportPath;
report.ServerReport.SetParameters(reportParameters);
现在你可以问的ReportViewer
渲染格式的报告,你preFER,它会回报给你一个字节数组,你可以简单地传输到客户端或保存的地方:
Now you can ask the ReportViewer
to render the report in the format you prefer, it'll return to you a byte array that you can simply stream to the client or save somewhere:
byte[] reportContent = report.ServerReport.Render(reportFormat);
reportFormat
是字符串
所要求的格式,例如获得。 TIF
图像,你要问的图像
格式,对于 .PDF
文件,你要问PDF
(请参阅MSDN其他支持的格式,就取决于你使用的版本)。
reportFormat
is a string
with the required format, for example to get a .TIF
image you have to ask for the "IMAGE"
format, for a .PDF
file you have to ask for "PDF"
(consult MSDN for other supported formats, they depends on the version you're using).
现在你可以简单地保存 reportContent
来的文件(或流式处理的响应,加入适量头):
Now you can simply save reportContent
to a file (or to stream it in the response, adding appropriate headers):
System.IO.File.WriteAllBytes(path, reportContent);
这篇关于如何转换为图像的报告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!