Add extra text above header while exporting Telerik RadGridView in WPF

2 posts, 0 answers
  1. Muhammad
    Muhammad avatar
    1 posts
    Member since:
    Dec 2011

    Posted 19 May 2016 Link to this post

    While exporting data from Telerik RadGridView in WPF.
    How can I add some extra text on above the header? Like if I need to add the name of the company and list name.
    Can anyone help me in this regard?
  2. Dilyan Traykov
    Dilyan Traykov avatar
    613 posts

    Posted 20 May 2016 Link to this post

    Hello Muhammad,

    With R1 2016, the new ExportToRadFixedDocument and ExportToWorkbook methods were introduced. You can use them if you need to modify the content of the exported RadGridView and avoid styling the document manually.

    Bear in mind that you will need to add the following references:

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

    Here's an example of how to use them:

    private void Export()
        //Instantiate the RadFixedDocument object
        RadFixedDocument fixedDoc = this.ExportableGridView.ExportToRadFixedDocument();
        //Modify the RadFixedDocument object
        foreach (var page in fixedDoc.Pages)
            var actualPage = page as RadFixedPage;
        //Export the RadFixedDocument to a PDF file
        SaveFileDialog dialog = new SaveFileDialog();
        dialog.DefaultExt = "*.pdf";
        dialog.Filter = String.Format("{1} files (*.{0})|*.{0}|All files (*.*)|*.*", "pdf", "Pdf");
        dialog.FilterIndex = 1;
        if (dialog.ShowDialog() == true)
            var provider = new PdfFormatProvider();
            using (var output = dialog.OpenFile())
                provider.Export(fixedDoc, output);
    private void Export()
        //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);

    You can also have a look at the RadPdfProcessing and RadSpreadProcessing documentation for more information on how to use RadFixedDocument and Workbook.

    Dilyan Traykov
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Back to Top