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

Get list of valid export types/strings.

5 Answers 222 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Xorcist
Top achievements
Rank 1
Xorcist asked on 17 Nov 2015, 08:01 PM

I know there is a listing in the documentation about what strings can be used to do programmatic exporting.

But is there a way to programmatically get this list?

Having to put a static array of strings into my code to validate my export parameters is very limiting.

It would be much nicer if I could leverage the reporting library to assist me in this validation.

 

P.S. Just letting the code throw an exception is not really acceptable.

5 Answers, 1 is accepted

Sort by
0
Stef
Telerik team
answered on 19 Nov 2015, 03:11 PM
Hello Xorcist,

Report Viewers models load internally only the suitable export options (based on loaded assemblies). The WPF and WinForms ReportViewer controls have RenderingExtensions collections providing information for the loaded export options. In the case of the Silverlight and HTML5 Viewers, you can send a request to the corresponding Reporting service to get a list of the available export options.
An example with the Reporting REST service:
request:
 
possible response:
[{"name":"PDF","localizedName":"Acrobat (PDF) file"},{"name":"CSV","localizedName":"CSV (comma delimited)"},{"name":"XLS","localizedName":"Excel 97-2003"},{"name":"XLSX","localizedName":"Excel Worksheet"},{"name":"PPTX","localizedName":"PowerPoint Presentation"},{"name":"RTF","localizedName":"Rich Text Format"},{"name":"IMAGE","localizedName":"TIFF file"},{"name":"MHTML","localizedName":"Web Archive"},{"name":"DOCX","localizedName":"Word Document"},{"name":"XPS","localizedName":"XPS Document"}]



When you use custom UI you have full control over the export options, where the available rendering extensions are listed in the Rendering Extensions help article.

Open XML format like DOCX, PPTX, XLSX require references to Telerik.Reporting.OpenXmlRendering.dll and Open XML SDK 2.0 for Microsoft Office (DocumentFormat.OpenXml.dll v.2.0.5022.0 or above with proper binding redirect).

​XPS rendering extension requires Telerik.Reporting.XpsRendering assembly (Telerik.Reporting.XpsRendering.dll).


Rendering extensions marked as multi-stream must be handled programmatically  - Exporting Report Programmatically.


I hope this information is helpful.

Regards,
Stef
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
Xorcist
Top achievements
Rank 1
answered on 19 Nov 2015, 04:12 PM
So if I just want to get my hands on the RenderingExtension collection... how can I do that. I can't seem to find any documentation on it. And I don't have the option of calling a web service to get that list provided above, but that is what I'm trying to get, only in C#.
0
Stef
Telerik team
answered on 20 Nov 2015, 04:26 PM
Hi Xorcist,

If you are using the HTML5 Viewer or the Silverlight ReportViewer, there is a Reporting REST service delivering content at the client. These services can bring a list with the loaded export options.

If you are using the WPF/WinForms ReportViewer controls, they have RenderingExtensions properties which contains information about the available the export options.


Please elaborate on the scenario, which viewer control is used and how the list of the possible export options should be used.

Regards,
Stef
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
Xorcist
Top achievements
Rank 1
answered on 20 Nov 2015, 05:23 PM

Thing is... I'm not using a viewer. Telerik.ReportViewer.WebForms.dll is part of the parent project, but in this scenario I'm using the ReportProcessor and InstanceReport classes to load my reports from *.trdx files, and directly export them to the format specified by the user.

And all of that works 100%, but I want my program to be flexible enough that if a new Telerik.Reporting version comes along, it pulls the valid export list from the Telerik libraries, and not an array list of my own creation (based off documentation which could change). So that way the user can be provided with a list of valid exports no matter what.

Secondly the list also is used to validate the export, if the user bypasses my interface, with a direct URL call, and the format provided is not in the export list, I return an appropriate response. I do not want the application to throw a hard 500 exception back at the user.

0
Stef
Telerik team
answered on 25 Nov 2015, 10:42 AM
Hi,

The old ASP.NET WebForms ReportViewer assembly cannot be used for obtaining the available rendering extensions. My recommendation is to add a Reporting REST service in the application and make a request for formats (using the VS item template will be easier). This will give you the list of available rendering extensions throughout the application.

For example:

 
              // Create an HttpClient instance
              HttpClient client = new HttpClient();
 
              // Send a request asynchronously continue when complete
              client.GetAsync("http://localhost:27787/api/reports/formats").ContinueWith(
                  (requestTask) =>
                  {
                      // Get HTTP response from completed task.
                      HttpResponseMessage response = requestTask.Result;
 
                      // Check that response was successful or throw exception
                      response.EnsureSuccessStatusCode();
 
                      //// Read response asynchronously
                      response.Content.ReadAsStringAsync().ContinueWith(
                                  (readTask) =>
                                  {
                                      var result = readTask.Result;
                                      //Do something with the result which is a json serialized list of export options           
                                  });
                  });
         


Regards,
Stef
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
Tags
General Discussions
Asked by
Xorcist
Top achievements
Rank 1
Answers by
Stef
Telerik team
Xorcist
Top achievements
Rank 1
Share this question
or