I am sure that most of your data-driven applications require support for Microsoft Excel. Probably the best and most famous spreadsheet application known for data manipulation, MS Excel provides useful features such as calculations, graphing tools and pivot tables – things that are not so easy to do in a regular data-driven application.

RadGridView for WinForms offers data export to Excel out of the box, a handy feature that saves you the hassle to do this yourself. It supports two methods for exporting data:

  • Exporting through Primary Interop Assemblies, optimized for black & white printing. Here we provide a small intermediate export assembly, which accepts RadGridView to be exported as a parameter. The prerequisites for using this method are to have MS Office 2007 installed on the machine where the export would occur, or MS Office 2003 with installed Primary Interop Assemblies (PIA) [http://msdn2.microsoft.com/en-us/library/aa159923(office.11).aspx];

• Exporting through ExcelML – my personal favourite, because it is significantly faster than using PIAs, it does not require Excel to be installed on the machine, and can be customized to export most of the visual settings of the grid, such as alternating rows, conditional formatting, themes, and even cell formatting (dates, currencies, etc). This export method just generates an XML Spreadsheet schema (XMLSS), which is supported by all MS Excel versions since 2002 (MS Office XP). Using this method is pretty easy: 

ExportToExcelML export = new ExportToExcelML();  
export.RunExport(this.radGridView1, "ExportFile", ExportToExcelML.ExcelMaxRows._65536, true);  

Using the ExportToExcelML class allows for various export settings such of max spreadsheet rows, export of theme colors, export of hidden rows and columns, etc. More on the topic you could find in RadControls for WinForms help section.

In addition to Excel, you can also export RadGridView data to PDF with the help of Telerik Reporting. For more information, check Export and Printing RadGridView using Telerik Reporting.

 Enjoy with Export capabilities of RadGridView!

About the Author

Nikolay Diyanov

Diyanov is the Product Manager of the Native Mobile UI division at Progress. Delivering outstanding solutions that make developers' lives easier is his passion and the biggest reward in his work. In his spare time, Nikolay enjoys travelling around the world, hiking, sun-bathing and kite-surfing.

Find him on Twitter @n_diyanov or on LinkedIn.

Related Posts


Comments are disabled in preview mode.