7 Answers, 1 is accepted
The PictureBox report item is ignored during processing and this behavior is expected and by design. This information is available in the Design Considerations for CSV Rendering help article. Note that other data in the report such as TextBox is correctly exported and you can verify this from our online examples e.g. Invoice report.
the Telerik team
Sorry to revive this old thread but I have a similar issue and it appears ReportProcessor does not ignore PictureBox elements when rendering to CSV.
My report contains a PictureBox to display a logo. The AppPool identity has permission to access the directory and the file is displayed both on the website and in the Report Viewer. Clicking the button in the Report Viewer to export to CSV works correctly.
However, when attempting to produce the CSV through ReportProcessor I get the following exception: "Invalid image data. - Access to the path '[...]' is denied.".
As I want a CSV it isn't a problem that for some reason the ReportProcessor cannot populate the PictureBox - it won't be displayed anyway. However, the CSV output is always blank (2 byte long array) which I assume is because it has failed on the PictureBox.
Is there anything I can do to stop the ReportProcessor trying to fill a PictureBox while rendering to CSV? If not, is this a planned fix? Are you able to help with the directory access issue that is for some reason not allowing the ReportProcessor to read the image?
(Version 126.96.36.1996 for Telerik.Reporting and Telerik.Reporting.Services.WebApi)
The report processing happens at an earlier stage in the Report Life-cycle and before the rendering to CSV happens. The report processing still needs to process the PictureBox and when it does not have access you might encounter the described error message. One solution is to provide access to the image from the application which exports to CSV. Note that the PictureBox cannot be excluded conditionally based on the format you export to.
Another option is to prepare a different report without any PIctureBoxes which will be used only when rendering to CSV programmatically.
Thanks for your response.
I'd like to address the access denied issue as creating duplicates of every report is not an option. Any advice you can offer would be appreciated.
Both the web application and the Telerik Reporting API can access the image. I have used SysInternals ProcessMonitor to check for attempts to access the file. When the file is accessed by either the application or the Telerik Report Viewer API I can see corresponding SUCCESS events in ProcessMonitor. As expected, both the app and the Report Viewer use the Application Pool identity.
When calling RenderReport I expected to see FAIL events in ProcessMonitor but instead I see no attempts were made to access the file. If access to path is not the real reason for the "Invalid image data. - Access to the path '[...]' is denied.", what other issues could cause this?
It turned out my CSV file was empty because there was an issue with the parameters. The parameters were identical to those used when running the report through the reporting API. However, when the parameters are first passed to the MVC action, then passed to the ReportProcessor they do not convert in the same way:
- Booleans are converted to BIT through the API but not when called through the ReportProcessor directly.
- Single DateTime (JS) parameters passed to the API work fine but appear as NULL when passed to the ReportProcessor directly. Multi-value DateTime parameters worked fine through both methods.
So the workaround was a small C# method to convert the JObject properties to CLR objects which ReportProcessor can read without issue.
The "Access is denied" exception was a red herring. Although the message was "Invalid image data. - Access to the path '[...]' is denied.", I believe the exception to occur elsewhere as ReportProcessor made no attempts to access the path before failing with errors. The 'failing with errors' from the RenderingResult is also a red herring as ReportProcessor.RenderReport() returned the CSV successfully.
Thanks for your help Nasko.