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

Exporting To Excel With ReportViewer

8 Answers 2487 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Steven
Top achievements
Rank 1
Steven asked on 03 Nov 2014, 10:11 PM
Good Evening,

I understand that the export options for reports using the ReportViewer use the rendering extensions to exporting to a document in order to get the document to be as close as the original report, but I was wondering if there is a way around this.  Our clients want to be able to export the report to an excel document in a row by row fashion, in basically the format that the stored procedure returns the data, and then add some formatting changes.

The comma delimited csv format doesn't quite give them what they want because it also exports textboxes that are being used as labels. 

Is there a way to capture the exporting event, and export it similar to the way radgrids are exported to excel?

Thank you,
Steve
Daniel
Top achievements
Rank 1
commented on 24 Jan 2022, 05:07 PM

Como puedo exportar un informe que realicé en telerik a excel, estoy ocupando la extensión xls, sin embargo me lo entrega pero con el formato del informe, y yo pretendo pasarlo sin formato solo que respete las filas y las columnas.

8 Answers, 1 is accepted

Sort by
0
Steven
Top achievements
Rank 1
answered on 04 Nov 2014, 03:01 PM
Alright so I found out about setting configuration settings, and setting the NoStaticText property to true, which gets rid of the textboxes used as labels, and it works well.

I'm still wondering if there's a way to capture the event so styling can be added.  This way column sizes and be set, and some background color for the headers.  Can it be done?

Thanks,
Steve
0
Steven
Top achievements
Rank 1
answered on 05 Nov 2014, 04:03 PM
I've been trying to figure this out on my own, but to no avail...Is it possible?
0
Stef
Telerik team
answered on 06 Nov 2014, 03:46 PM
Hello Steven,

The Excel rendering is a logical rendering in which we aim to preserve the original reports layout. The report is exported in Excel based on the Design Considerations for Excel Rendering article.

The CSV rendering uses the standards described in the Design Considerations for CSV Rendering article. the CSV rendering can be adjusted with the CSV Device Information Settings. Still the produced CSV document will described the report structure and how data is rendered (data layout of the report).

In case you need only the data, you can create custom export method where you use the reports data, flatten it and concatenate it into strings before writing it in the CSV file.


In future, if it is an emergency, please use the support ticketing system where all inquiries are assigned automatically with response time based on the purchased support plan.

Regards,
Stef
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Steven
Top achievements
Rank 1
answered on 06 Nov 2014, 04:12 PM
Thank you for your reply.  Is there an example on what you described?  There doesn't seem to be an OnExportMethod for the report viewer. 

Thanks,
Steve
0
Stef
Telerik team
answered on 11 Nov 2014, 12:09 PM
Hi Steven,

If you refer to an example of applying the CSV device settings, they can be added for all viewers in the start project's configuration file. For the purpose:
  1. Declare Telerik.Reporting section - Telerik Reporting Configuration Section
  2. Use the Extensions element to add the settings from the CSV Device Information Settings

For example:

<configuration>
    <configSections>
        <section
                name="Telerik.Reporting"
                type="Telerik.Reporting.Configuration.ReportingConfigurationSection, Telerik.Reporting, Version=8.2.14.1107, Culture=neutral, PublicKeyToken=a9d7983dfcc261be"
                allowLocation="true"
                allowDefinition="Everywhere"/>
    </configSections>
    
     <Telerik.Reporting>
        <Extensions>
            <Render>
                <Extension name="CSV" >
                    <Parameters>
                        <Parameter name="NoHeader" value="true"/>
                        <Parameter name="NoStaticText" value="true"/>
                    </Parameters>
                </Extension>
            </Render>
        </Extensions>
    </Telerik.Reporting>
    ...
</configuration>


If you are going to use the ReportProcessor to export the report, you can directly pass the settings by key.
Telerik.Reporting.Processing.ReportProcessor reportProcessor =
    new Telerik.Reporting.Processing.ReportProcessor();
 
System.Collections.Hashtable deviceInfo =
    new System.Collections.Hashtable();
 
deviceInfo.Add("NoHeader", true);
deviceInfo.Add("NoStaticText", true);
 
Telerik.Reporting.TypeReportSource typeReportSource =
             new Telerik.Reporting.TypeReportSource();
 
// reportName is the Assembly Qualified Name of the report
typeReportSource.TypeName = reportName;
 
Telerik.Reporting.Processing.RenderingResult result =
    reportProcessor.RenderReport("CSV", typeReportSource, deviceInfo);


If you need further help, please specify the used viewer and Telerik Reporting version. Also elaborate on the reason to perform the operation on viewer's event.

Regards,
Stef
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
May
Top achievements
Rank 1
answered on 19 Feb 2015, 06:05 AM
I tried to set the noheader= true in app.config file when rendering the CSV file, the textbox name is still on the header. My telerik report version is Q2 2014 in visual studio 2013 premium.
0
Lobna
Top achievements
Rank 1
answered on 23 Feb 2015, 12:41 PM
I used Telerik.Reporting.OpenXmlRendering.dll to add some export options like Excel Worksheet. Now When I publish my project on the server, it didn't show the new added export options as working locally. 
Can anyone help, please?
0
Stef
Telerik team
answered on 23 Feb 2015, 12:52 PM
Hi May,

Both settings work as expected in Telerik Reporting Q2 2014 and later versions. Please verify the Telerik Reporting section is correctly configured in the application's configuration file, or if you are using the ReportProcessor check the passed device info settings.

If you need further help, feel free to open a support ticket and send us a runnable demo project to check your settings.

Regards,
Stef
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
General Discussions
Asked by
Steven
Top achievements
Rank 1
Answers by
Steven
Top achievements
Rank 1
Stef
Telerik team
May
Top achievements
Rank 1
Lobna
Top achievements
Rank 1
Share this question
or