Exporting To Excel With ReportViewer

9 posts, 0 answers
  1. Steven
    Steven avatar
    4 posts
    Member since:
    Nov 2013

    Posted 03 Nov 2014 Link to this post

    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
  2. Steven
    Steven avatar
    4 posts
    Member since:
    Nov 2013

    Posted 04 Nov 2014 in reply to Steven Link to this post

    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
  3. Steven
    Steven avatar
    4 posts
    Member since:
    Nov 2013

    Posted 05 Nov 2014 Link to this post

    I've been trying to figure this out on my own, but to no avail...Is it possible?
  4. Stef
    Admin
    Stef avatar
    3610 posts

    Posted 06 Nov 2014 Link to this post

    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.

     
  5. Steven
    Steven avatar
    4 posts
    Member since:
    Nov 2013

    Posted 06 Nov 2014 in reply to Stef Link to this post

    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
  6. Stef
    Admin
    Stef avatar
    3610 posts

    Posted 11 Nov 2014 Link to this post

    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.

     
  7. May
    May avatar
    1 posts
    Member since:
    Dec 2014

    Posted 19 Feb 2015 in reply to Stef Link to this post

    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.
  8. Lobna
    Lobna avatar
    14 posts
    Member since:
    Jan 2013

    Posted 23 Feb 2015 Link to this post

    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?
  9. Stef
    Admin
    Stef avatar
    3610 posts

    Posted 23 Feb 2015 Link to this post

    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.

     
Back to Top