GridDocumentExportOptions Class
Contains options that define how Grid data is exported to a document.
Namespace: DevExpress.Blazor
Assembly: DevExpress.Blazor.v25.1.dll
NuGet Package: DevExpress.Blazor
Declaration
public abstract class GridDocumentExportOptions :
GridDocumentExportOptionsBase
Remarks
The following example exports selected rows to PDF and customizes the output document’s appearance:
@rendermode InteractiveServer
@using DevExpress.Drawing;
@inject WeatherForecastService ForecastService
<DxGrid @ref="Grid" Data="@forecasts">
<Columns>
<DxGridSelectionColumn Width="60px" AllowSelectAll="true" />
<DxGridDataColumn Caption="Date" FieldName="Date" />
<DxGridDataColumn Caption="Temperature (C)" FieldName="TemperatureC" />
<DxGridDataColumn Caption="Temperature (F)" FieldName="TemperatureF" />
<DxGridDataColumn Caption="Summary" FieldName="Summary" />
</Columns>
<ToolbarTemplate>
<DxToolbar>
<DxToolbarItem Text="Export to PDF" Click="ExportPdf_Click" BeginGroup="true" />
</DxToolbar>
</ToolbarTemplate>
</DxGrid>
@code {
IGrid Grid;
private WeatherForecast[]? forecasts;
protected override async Task OnInitializedAsync() {
forecasts = await ForecastService.GetForecastAsync(DateOnly.FromDateTime(DateTime.Now));
}
async Task ExportPdf_Click() {
await Grid.ExportToPdfAsync("ExportResult", new GridPdfExportOptions() {
ExportSelectedRowsOnly = true, // Exports only selected rows
CustomizeCell = OnCustomizeCell, // Customizes table cell appearance
CustomizeDocument = OnCustomizeDocument, // Customizes overall document appearance
CustomizeDocumentHeader = OnCustomizeDocumentHeader, // Adds and customizes a document header
});
}
void OnCustomizeDocument(GridDocumentExportCustomizeDocumentEventArgs args) {
// Sets default font settings for all elements
args.DefaultElementStyle.Font = new DXFont("Times New Roman", 12, DXFontStyle.Regular);
// Switches the page orientation to landscape
args.Landscape = true;
}
void OnCustomizeCell(GridDocumentExportCustomizeCellEventArgs args) {
// Sets border settings for all table cells
args.ElementStyle.BorderColor = System.Drawing.Color.DarkGray;
args.ElementStyle.BorderDashStyle = DevExpress.XtraPrinting.BorderDashStyle.Dash;
// Sets style settings for header cells
if (args.AreaType == DocumentExportAreaType.Header) {
args.ElementStyle.BackColor = System.Drawing.Color.LightGray;
args.ElementStyle.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;
args.ElementStyle.Font = new DXFont("Arial", 12, DXFontStyle.Bold);
}
args.Handled = true;
}
void OnCustomizeDocumentHeader(GridDocumentExportCustomizeDocumentHeaderFooterEventArgs args) {
// Adds a document header
args.Text = "Weather Forecast";
// Sets header style settings
args.ElementStyle.Font = new DXFont("Arial", 12, DXFontStyle.Regular);
args.ElementStyle.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;
}
}
Inheritance
Object
GridDocumentExportOptionsBase
GridDocumentExportOptions
See Also