How to convert the report to an image? [closed]

匆匆过客 提交于 2019-12-21 06:38:10

问题


I use Report viewer to show my reports .


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 ?


回答1:


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);

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 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).

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);


来源:https://stackoverflow.com/questions/14013295/how-to-convert-the-report-to-an-image

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!