Style Exported XLSX and PDF Documents

If you need to style the exported RadGridView differently from its default style when exporting using the ExportToXlsx & ExportToPdf methods, you can use the ElementExportingToDocument event and through the GridViewElementExportingToDocumentEventArgs set the VisualParameters property to a new instance of the CellSelectionStyle class.

Example 1: Style exported XLSX/PDF document

private void ElementExportingToDocument(object sender, GridViewElementExportingToDocumentEventArgs e) 
{ 
    if (e.Element == ExportElement.HeaderRow) 
    { 
        (e.VisualParameters as GridViewDocumentVisualExportParameters).Style = new CellSelectionStyle() 
        { 
            FontSize = 20, 
            IsBold = true, 
            Fill = new PatternFill(PatternType.Solid, Colors.Blue, Colors.Blue), 
            ForeColor = new ThemableColor(Colors.White) 
        }; 
    } 
    else if (e.Element == ExportElement.Row) 
    { 
        (e.VisualParameters as GridViewDocumentVisualExportParameters).Style = new CellSelectionStyle() 
        { 
            Fill = new PatternFill(PatternType.Solid, Colors.White, Colors.White), 
            ForeColor = new ThemableColor(Colors.Black) 
        }; 
    } 
} 
Private Sub ElementExportingToDocument(ByVal sender As Object, ByVal e As GridViewElementExportingToDocumentEventArgs) 
    If e.Element = ExportElement.HeaderRow Then 
        TryCast(e.VisualParameters, GridViewDocumentVisualExportParameters).Style = New CellSelectionStyle() With { 
            .FontSize = 20, 
            .IsBold = True, 
            .Fill = New PatternFill(PatternType.Solid, Colors.Blue, Colors.Blue), 
            .ForeColor = New ThemableColor(Colors.White) 
        } 
    ElseIf e.Element = ExportElement.Row Then 
        TryCast(e.VisualParameters, GridViewDocumentVisualExportParameters).Style = New CellSelectionStyle() With { 
            .Fill = New PatternFill(PatternType.Solid, Colors.White, Colors.White), 
            .ForeColor = New ThemableColor(Colors.Black) 
        } 
    End If 
End Sub 

See Also

In this article
Not finding the help you need? Improve this article