Edit this page

Modify RadGridView's Content Before Exporting

In R1 2016, we have introduced two new extension methods related to the exporting of RadGridView - ExportToWorkbook() and ExportToRadFixedDocument(). You can use them if you need to modify the content of the exported RadGridView and avoid styling the document manually.

Assembly References

ExportToWorkbook and ExportToRadFixedDocument methods use additional libraries so you need to add references to the following assemblies:

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


The method exports the associated RadGridView to a Workbook object.

Example 1: Export RadGridView to a Workbook on Button click:

  private void Button_Click(object sender, RoutedEventArgs e)
        //Instantiate the Workbook object
        Workbook workbook = this.clubsGrid.ExportToWorkbook();

        //Modify the created Workbook
        CellStyle wbStyle = workbook.Styles["Normal"];
        wbStyle.ForeColor = new ThemableColor(Colors.Green);
        wbStyle.FontFamily = new ThemableFontFamily(ThemeFontType.Major);
        wbStyle.FontSize = UnitHelper.PointToDip(16);
        wbStyle.VerticalAlignment = RadVerticalAlignment.Top;

        //Export the Workbook to an Excel file
        SaveFileDialog dialog = new SaveFileDialog();
        dialog.DefaultExt = ".xlsx";
        dialog.Filter = String.Format("{1} files (.{0})|.{0}|All files (.)|.*", "xlsx", "Excel");
        dialog.FilterIndex = 1;

        if (dialog.ShowDialog() == true)
            var provider = new XlsxFormatProvider();
            using (var output = dialog.OpenFile())
                provider.Export(workbook, output);


The method exports the associated RadGridView to a RadFixedDocument object.

Example 2: Export RadGridView to a RadFixedDocument on Button click:

private void Button2_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);

Both methods can be overloaded and take GridViewDocumentExportOptions as parameter. You can use it to set the following export options:
  • Culture
  • Items
  • ShowColumnFooters
  • ShowGroupFooters
  • ShowColumnHeaders
  • ExportDefaultStyles

ExportToRadFixedDocument method utilizes PdfProcessing library and ExportToWorkbook method utilizes SpreadProcessing library. You can check their documentation for more information on how to modify them.

See Also

Is this article helpful? Yes / No
Thank you for your feedback!

Give article feedback

Tell us how we can improve this article