This is a migrated thread and some comments may be shown as answers.

Exclude Picture Box From Exporting to CSV

7 Answers 39 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Ram
Top achievements
Rank 1
Ram asked on 02 Dec 2011, 01:27 PM
Hi,

I've a picture box in my report. While exporting to . CSV i'm getting an empty file.

Is it possible to exclude the picture box while exporting only to CSV format or how to resolve the issue.

Thanks & Regards
Ramakrishnan S

7 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 02 Dec 2011, 02:38 PM
Hello Ram,

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.

Greetings,
Steve
the Telerik team

Q3’11 of Telerik Reporting is available for download. Register for the What's New in Data Tools webinar to see what's new and get a chance to WIN A FREE LICENSE!

0
Owen
Top achievements
Rank 1
answered on 29 Aug 2017, 09:18 AM

Hi Steve,

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?

Thanks,

Owen

(Version 11.0.17.406 for Telerik.Reporting and Telerik.Reporting.Services.WebApi)

 

0
Owen
Top achievements
Rank 1
answered on 29 Aug 2017, 09:20 AM
ParameterCollection reportParameters = ParseReportParameterJson(reportParams);
ReportProcessor reportProcessor = new ReportProcessor();
Hashtable deviceInfo = new Hashtable();
 
XmlReportSource reportSource = new XmlReportSource();
reportSource.Xml = GetReportXml(reportId) ;
reportSource.Parameters.AddRange(reportParameters);
 
RenderingResult result = reportProcessor.RenderReport("CSV", reportSource, deviceInfo);
0
Owen
Top achievements
Rank 1
answered on 29 Aug 2017, 09:21 AM
ParameterCollection reportParameters = ParseReportParameterJson(reportParams);
ReportProcessor reportProcessor = new ReportProcessor();
Hashtable deviceInfo = new Hashtable();
 
XmlReportSource reportSource = new XmlReportSource();
reportSource.Xml = GetReportXml(reportId) ;
reportSource.Parameters.AddRange(reportParameters);
 
RenderingResult result = reportProcessor.RenderReport("CSV", reportSource, deviceInfo);
0
Nasko
Telerik team
answered on 01 Sep 2017, 08:01 AM
Hello Owen,

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.

Regards,
Nasko
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Owen
Top achievements
Rank 1
answered on 01 Sep 2017, 04:12 PM

Hi Nasko,

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?

Thanks,

Owen

0
Owen
Top achievements
Rank 1
answered on 06 Sep 2017, 01:47 PM

Hi Nasko,

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.

Regards,

Owen

Tags
General Discussions
Asked by
Ram
Top achievements
Rank 1
Answers by
Steve
Telerik team
Owen
Top achievements
Rank 1
Nasko
Telerik team
Share this question
or