Export to Word, Excel and Csv with RadGridView for Silverlight

Thursday, January 22, 2009 by Vladimir Enchev | Comments 9

I’m happy to announce that with Q1 2009 version of RadControls for WPF and Silverlight you will be able to get the grid data in different formats using three extension methods: ToHtml(), ToText() and ToCsv().

I’ve made small demo to demonstrate how to use all these in a Silverlight web application for Word, Excel and Csv export:

Untitled

[Download]

9 Comments

  • Giorgio 24 Jan 2009
    When is Q1 2009 of the Silverlight Toolset scheduled to ship?
  • Valentin Stoychev 24 Jan 2009
    Hi Giorgio Q1 is scheduled to arrive around the end of February.
  • Jonathan Miller 12 Mar 2009
    Great example, thanks.  Just a friendly fyi, for those of you fully implementing this in Silverlight and will have no buttons on the HTML side, add an iframe on your in your host aspx page, to another .aspx page (download.aspx).  Then using javascript, pass a query string to the download.aspx page (which will be in the iframe) with the report name. In your download.aspx file, send the filestream on page load.  This is a nice streamlined solution.
  • Yonatan 30 Mar 2009
    Was export to excel feature released?
  • Vlad 10 Apr 2009
    Hi  Yonatan,

    Indeed this was release in Q1 2009. Please check also this post for more info:
    http://blogs.telerik.com/vladimirenchev/posts/09-04-02/new_feature_export_styling_and_formatting_in_radgridview_for_silverlight_wfp.aspx

    Vlad
  • loring vogel 17 Mar 2010
    I need this to be in my silverlight app itself not in the surrounding html.

    Is there a way I can add a silverlight button to one of my pages and have it perform this functionality?  And is there a way to get the export to include all my data not just the current page of data?

    Can you post a sample of this usage incorporated into a silverlight app rather than outside of it?

  • Vlad 18 Mar 2010
    Hi,

    The sample can be found here:
    http://demos.telerik.com/silverlight/#GridView/Printing

    You can check also this blog post for Silverlight 4 advanced printing options.

    Vlad
  • Niki 07 Oct 2010
    I want ask You is there option to export data only? So field image will not included during export to excel. Thx!!
  • Rodney Foley 06 Nov 2010
    The ToCsv() does not work in 2010 Q2 Silverlight release, while ToExcelML() and ToHtml() work just fine. So if the others work and one doesn't and they are operating on the same data then looks like a bug in GridViewExportWriter.RenderDataCells method.

    ToCsv() throws the following exception:
    System.NullReferenceException occurred
      Message=Object reference not set to an instance of an object.
      StackTrace:
           at Telerik.Windows.Controls.GridViewExportWriter.RenderDataCells(Object item)
           at Telerik.Windows.Controls.GridViewExportWriter.RenderDataRows(IEnumerable items)
           at Telerik.Windows.Controls.GridViewExportWriter.Render()
           at Telerik.Windows.Controls.GridView.GridViewDataControl.Export(Stream stream, GridViewExportOptions options)
           at Telerik.Windows.Controls.ExportExtensions.GetContent(ExportFormat format, GridViewDataControl source, Boolean includeHeader, Boolean includeFooter, IEnumerable items)
           at Telerik.Windows.Controls.ExportExtensions.ToCsv(GridViewDataControl source, Boolean includeHeader)
           at FunWithRia.SelectionDetailsChildWindow.exportToCsv_Click(Object sender, RoutedEventArgs e)
      InnerException: 

    System.NullReferenceException occurred 
      Message=Object reference not set to an instance of an object
      StackTrace: 
           at Telerik.Windows.Controls.GridViewExportWriter.RenderDataCells(Object item) 
           at Telerik.Windows.Controls.GridViewExportWriter.RenderDataRows(IEnumerable items) 
           at Telerik.Windows.Controls.GridViewExportWriter.Render() 
           at Telerik.Windows.Controls.GridView.GridViewDataControl.Export(Stream stream, GridViewExportOptions options) 
           at Telerik.Windows.Controls.ExportExtensions.GetContent(ExportFormat format, GridViewDataControl source, Boolean includeHeader, Boolean includeFooter, IEnumerable items) 
           at Telerik.Windows.Controls.ExportExtensions.ToCsv(GridViewDataControl source, Boolean includeHeader) 
           at FunWithRia.SelectionDetailsChildWindow.exportToCsv_Click(Object sender, RoutedEventArgs e) 
      InnerException:  
     

Add comment

  1. Formatting options
       
     
     
     
     
       
  2. (optional, emails won't be shown on public pages)
  3. (optional)