Back to Devexpress

GridXlExportOptions.CustomizeSheetFooter Property

blazor-devexpress-dot-blazor-dot-gridxlexportoptions-09452eab.md

latest4.5 KB
Original Source

GridXlExportOptions.CustomizeSheetFooter Property

Allows you to add rows below grid content in the output document.

Namespace : DevExpress.Blazor

Assembly : DevExpress.Blazor.v25.2.dll

NuGet Package : DevExpress.Blazor

Declaration

csharp
public Action<GridExportCustomizeSheetHeaderFooterEventArgs> CustomizeSheetFooter { get; set; }

Property Value

TypeDescription
Action<GridExportCustomizeSheetHeaderFooterEventArgs>

A delegate method that customizes the document footer area.

|

Remarks

The grid calls the CustomizeSheetFooter delegate method after grid data is exported. You can write the action handler to perform the following actions:

razor
@using DevExpress.Printing.ExportHelpers
@using DevExpress.Export
@using DevExpress.Export.Xl

<DxGrid @ref="@Grid" Data="@Data">
    <Columns>
        <DxGridDataColumn FieldName="ContactName" />
        <DxGridDataColumn FieldName="ContactTitle" />
        <DxGridDataColumn FieldName="CompanyName" />
        <DxGridDataColumn FieldName="City" />
        <DxGridDataColumn FieldName="Country" />
        <DxGridDataColumn FieldName="Phone" />
    </Columns>
</DxGrid>
<DxButton Text="Export to XLSX" Click="ExportXlsx_Click" />

@code {
    DxGrid Grid { get; set; }
    IEnumerable<Supplier> Data { get; set; }
    protected override async Task OnInitializedAsync() {
        Data = await NwindDataService.GetSuppliersAsync();
    }
    async Task ExportXlsx_Click() {
        var options = new GridXlExportOptions();
        options.CustomizeSheetFooter = e => {
            // Add an empty row to the document's footer.
            e.ExportContext.AddRow();

            // Create a new row.
            var firstRow = new CellObject();
            firstRow.Value = "The report is generated from the Northwind database.";
            var rowFormat = new XlFormattingObject();
            rowFormat.Font = new XlCellFont();
            rowFormat.Font.Size = 18;
            rowFormat.Font.Bold = true;
            firstRow.Formatting = rowFormat;
            e.ExportContext.AddRow(new[] { firstRow });

            // Create one more row.
            var secondRow = new CellObject();
            secondRow.Value = "The addresses and phone numbers are fictitious.";
            rowFormat.Font.Size = 14;
            rowFormat.Font.Bold = false;
            rowFormat.Font.Italic = true;
            secondRow.Formatting = rowFormat;
            e.ExportContext.AddRow(new[] { secondRow });
        };
        options.CustomizeSheetHeader = e => {
            // See the CustomizeSheetHeader action description.
        };
       await Grid.ExportToXlsxAsync("ExportResult", options);
    }
}

The CustomizeSheetHeader action allows you to add rows above grid content in the output document.

For additional information about data export in the Grid component, refer to the following topic: Export Blazor Grid Data to XLS/XLSX.

See Also

GridXlExportOptions Class

GridXlExportOptions Members

DevExpress.Blazor Namespace