corelibraries-devexpress-dot-xtraprinting-dot-xlsxexportoptionsex-b541d9d4.md
Allows you to customize the output document’s settings. Only available in data-aware export mode.
Namespace : DevExpress.XtraPrinting
Assembly : DevExpress.Printing.v25.2.Core.dll
NuGet Package : DevExpress.Printing.Core
public event CustomizeSheetSettingsEventHandler CustomizeSheetSettings
Public Event CustomizeSheetSettings As CustomizeSheetSettingsEventHandler
The CustomizeSheetSettings event allows you to do the following:
Note
The CustomizeSheetSettings event is not currently supported when exporting data from Advanced Banded Grid Views.
The e.Sheet.Name property allows you to specify the worksheet name. When naming a worksheet, consider the following constraints:
An ArgumentException occurs when the sheet name does not meet the aforementioned requirements.
This example handles the XlsxExportOptionsEx.CustomizeSheetSettings event to specify export settings for an XLSX document that originates from a Grid Control. The ExportContext.SetFixedHeader method is used to anchor the output document’s header to the top, and to set the fixed header height. The ExportContext.AddAutoFilter method adds the AutoFilter button to the column header cells.
View Example: How to: Customize the GridControl's Data-Aware Export Output
void options_CustomizeSheetSettings(CustomizeSheetEventArgs e) {
// Anchor the output document's header to the top and set its fixed height.
const int lastHeaderRowIndex = 15;
e.ExportContext.SetFixedHeader(lastHeaderRowIndex);
// Add the AutoFilter button to the document's cells corresponding to the grid column headers.
e.ExportContext.AddAutoFilter(new XlCellRange(new XlCellPosition(0, lastHeaderRowIndex), new XlCellPosition(5, 100)));
}
Private Sub options_CustomizeSheetSettings(ByVal e As CustomizeSheetEventArgs)
' Anchor the output document's header to the top and set its fixed height.
Const lastHeaderRowIndex As Integer = 15
e.ExportContext.SetFixedHeader(lastHeaderRowIndex)
' Add the AutoFilter button to the document's cells corresponding to the grid column headers.
e.ExportContext.AddAutoFilter(New XlCellRange(New XlCellPosition(0, lastHeaderRowIndex), New XlCellPosition(5, 100)))
End Sub
The following code snippet displays the current page number in the right header section:
private void Options_CustomizeSheetSettings(DevExpress.Export.CustomizeSheetEventArgs e)
{
e.Sheet.HeaderFooter.OddHeader = XlHeaderFooter.FromLCR(null, null, XlHeaderFooter.PageNumber);
}
Private Sub options_CustomizeSheetSettings(ByVal e As CustomizeSheetEventArgs)
e.Sheet.HeaderFooter.OddHeader = XlHeaderFooter.FromLCR(null, null, XlHeaderFooter.PageNumber)
End Sub
For more information, review the following help topic: Use the Excel Export API to Add Headers and Footers to a Worksheet Printout.
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the CustomizeSheetSettings event.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.
winforms-grid-customize-data-aware-export-output/CS/GridDataAwareExportCustomization/Form1.cs#L47
// Subscribe to export customization events.
options.CustomizeSheetSettings += options_CustomizeSheetSettings;
options.CustomizeSheetHeader += options_CustomizeSheetHeader;
winforms-grid-customize-data-aware-export-output/VB/GridDataAwareExportCustomization/Form1.vb#L50
' Subscribe to export customization events.
AddHandler options.CustomizeSheetSettings, AddressOf options_CustomizeSheetSettings
AddHandler options.CustomizeSheetHeader, AddressOf options_CustomizeSheetHeader
See Also