Telerik blogs

The RadControls for WinForms Q2 2010 beta release has been live for a couple of weeks now, and we have been getting excellent feedback on the fancy new features. Along with several brand new components (RadListControl, RadPageView and RadDesktopAlert to name a few), we have introduced a completely redesigned grid, along with numerous new features and possibilities.

Up until now we have supported Export to Excel capabilities in RadGridView, and not much more. Although ExportToExcelML offers some cool and unique features, exporting only to Excel was not enough for our clients. Our integration with Telerik Reporting could not suit all of our client's requirements either.

Now, with the Q2 2010 beta we are introducing three (3!) new export formats:

  • CSV
  • HTML and
  • PDF

And that is not all the news. These new methods support a very wide range of useful and exclusive features. Download Q2 Beta of RadControls for WinForms to check them out.

Export to PDF

Export to PDF - RadGridView for WinForms Q2 2010 

Using the ExportToPDF class follows the whole Telerik export design. Actually, RadGridView renders as html and converts to pdf afterwards. This means that exporting to pdf will support all features which are presented in the Export to HTML method (see below). In addition, we have provided numerous ways for controlling specific PDF properties such as author, title, page size etc.:

void ExportToPdfMethod(RadGridView radGridView, string filePath)
{
    ExportToPDF pdfExporter = new ExportToPDF(radGridView1);
    pdfExporter.ExportVisualSettings = true;
    pdfExporter.FileExtension = "pdf"; ////this is the default value anyway
    pdfExporter.HiddenColumnOption = HiddenOption.DoNotExport;
    pdfExporter.HiddenRowOption = HiddenOption.ExportAlways;
    pdfExporter.PageTitle = "My PDF Page Title"; //apears to every pdf page
    pdfExporter.Scale = 1.4f;
    pdfExporter.SummariesExportOption = SummariesOption.DoNotExport;
    pdfExporter.TableBorderThickness = 0;
 
    pdfExporter.PdfExportSettings.Author = "Me";
    pdfExporter.PdfExportSettings.Title = "PDF Title"; //this is the specific pdf file title
    pdfExporter.PdfExportSettings.EnableAdd = false;
    pdfExporter.PdfExportSettings.EnableCopy = true;
    pdfExporter.PdfExportSettings.EnableModify = false;
    pdfExporter.PdfExportSettings.EnablePrinting = true;
 
 
    //set landscape A4 size
    pdfExporter.PdfExportSettings.PageHeight = 210;
    pdfExporter.PdfExportSettings.PageWidth = 297;
 
    pdfExporter.RunExport(filePath);
}
 

Export to CSV

This method offers excellent export performance. It creates a csv file and supports many formatting events to allow for customization of the exported data.  Just create an ExportToCSV instance with the grid to export as parameter and use the RunExport method, similar to the well-known ExportToExcelML class:

void ExportToCsvMethod(RadGridView radGridView, string filePath)
{
    ExportToCSV csvExporter = new ExportToCSV(radGridView);
    csvExporter.FileExtension = "csv"; //this is the default value anyway
    csvExporter.HiddenColumnOption = HiddenOption.DoNotExport;
    csvExporter.HiddenRowOption = HiddenOption.ExportAlways;
    csvExporter.SummariesExportOption = SummariesOption.ExportAll;
 
    csvExporter.RunExport(filePath);
}
 

Export to HTML

Export to HTML - RadGridView for WinForms Q2 2010 

The ExportToHTML class has similar structure. It creates a html formatted file, which can be opened with MS Excel, MS World or any internet browser. It supports very close to ExportToExcelML options, events and features.  Feel free to experiment with the various options in beta:

void ExportToHtmlMethod(RadGridView radGridView, string filePath)
{
    ExportToHTML htmlExporter = new ExportToHTML(radGridView);
    htmlExporter.ExportVisualSettings = true;
    htmlExporter.FileExtension = "doc";
    htmlExporter.HiddenColumnOption = HiddenOption.DoNotExport;
    htmlExporter.HiddenRowOption = HiddenOption.ExportAsHidden;
    htmlExporter.SummariesExportOption = SummariesOption.ExportAll;
    htmlExporter.TableBorderThickness = 0;
    htmlExporter.Scale = 1.2f;
 
    htmlExporter.RunExport(filePath);
 
}
 
We hope that you will find the new exporting capabilities and features useful. Do not hesitate to give us your feedback and ideas on how to additionally improve GridView's exporting.

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

Comments are disabled in preview mode.