New to Telerik UI for WPF? Start a free 30-day trial
Style Exported XLSX and PDF Documents
Updated on Oct 1, 2025
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.
The class provides the following useful properties:
- CellBorders: Gets or sets the borders of the cells.
- Fill: Gets or sets the fill of the cells.
- FontFamily: Gets or sets the font family of the text of the cells.
- FontSize: Gets or sets the font size of the text.
- ForeColor: Gets or sets the foreground of the text of the cells.
- Format: Gets or sets the format of the text.
- HorizontalAlignment: Gets or sets the horizontal alignment.
- Indent: Gets or sets the intent of the cells.
- IsBold: Gets or sets the IsBold property of the cells.
- IsItalic: Gets or sets the isItalic property of the cells.
- IsLocked: Gets or sets the isLocked property of the cells.
- IsWrapped: Gets or sets the IsWrapped property of the cells.
- StyleName: Gets or sets the StyleName property of the cells.
- Underline: Gets or sets the Underline of the text in the cells.
- VerticalAlignment: Gets or sets the vertical alignment.
Example 1: Style exported XLSX/PDF document
C#
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)
};
}
}