New to Telerik UI for WPF? Download free 30-day trial

ExportToRadFixedDocument

In R1 2016, we introduced a new extension method related to the exporting of RadGridView - ExportToRadFixedDocument. You can use it if you need to modify the content of the exported RadGridView and avoid styling the document manually.

Assembly References

ExportToRadFixedDocument uses additional libraries so you need to add references to the following assemblies:

  • Telerik.Windows.Controls.GridView.Export.dll
  • Telerik.Windows.Documents.Core.dll
  • Telerik.Windows.Documents.Spreadsheet.dll
  • Telerik.Windows.Documents.Spreadsheet.FormatProviders.Pdf.dll
  • Telerik.Windows.Zip.dll

Usage

This method exports the associated RadGridView to a RadFixedDocument object. Example 1 shows how you can rotate the exported page before exporting.

Example 1: Export RadGridView to a RadFixedDocument and rotate the page 90 degrees

private void Button_Click(object sender, RoutedEventArgs e) 
    {    
        //Instantiate the RadFixedDocument object 
        RadFixedDocument fixedDoc = this.clubsGrid.ExportToRadFixedDocument(); 
 
        //Modify the RadFixedDocument object 
        foreach (var page in fixedDoc.Pages) 
        { 
            var actualPage = page as RadFixedPage; 
            actualPage.Rotation =  Telerik.Windows.Documents.Fixed.Model.Data.Rotation.Rotate90; 
        } 
 
        //Export the RadFixedDocument to a PDF file 
        SaveFileDialog dialog = new SaveFileDialog(); 
        dialog.DefaultExt = "*.pdf"; 
 
        if (dialog.ShowDialog() == true) 
        { 
 
            var provider = new PdfFormatProvider(); 
            using (var output = dialog.OpenFile()) 
            { 
                provider.Export(fixedDoc, output); 
            } 
        } 
    } 

GridViewDocumentExportOptions

The method can be overloaded and take GridViewDocumentExportOptions as a parameter. You can use it to set the following export options:

  • Culture
  • Items
  • ShowColumnFooters
  • ShowGroupFooters
  • ShowColumnHeaders
  • ExportDefaultStyles

The ExportToRadFixedDocument method utilizes the PdfProcessing library. You can check the respective documentation for more information on how to use the library.

See Also

In this article