Skip to main content
All docs
V24.2

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

TreeListXlExportOptions.CustomizeSheet Property

Allows you to customize sheet settings in the exported document.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.2.dll

NuGet Package: DevExpress.Blazor

#Declaration

C#
public Action<TreeListExportCustomizeSheetEventArgs> CustomizeSheet { get; set; }

#Property Value

Type Description
Action<TreeListExportCustomizeSheetEventArgs>

A delegate method that customizes sheet settings.

#Remarks

Implement a delegate for the CustomizeSheet action to customize settings of the sheet in the output document. Use the argument’s Sheet property to access sheet settings.

When you create a delegate for the CustomizeSheet action, the TreeList disables some predefined sheet settings that can be set in this handler. For instance, the auto filter is initially enabled for a TreeList header (the default setting). If you implement the delegate, the auto filter is disabled. You can use the AutoFilterRange property to enable the filter in the document.

Razor
<DxButton Text="Export to XLSX" Click="ExportXlsx_Click" />

<DxTreeList Data="TreeListData" KeyFieldName="Id" ParentKeyFieldName="ParentId" @ref="MyTreeList">
    <Columns>
        <DxTreeListDataColumn FieldName="Name" Caption="Task" />
        <DxTreeListDataColumn FieldName="EmployeeName" />
        <DxTreeListDataColumn FieldName="StartDate" />
        <DxTreeListDataColumn FieldName="DueDate" />
    </Columns>
</DxTreeList>

@code {
    ITreeList MyTreeList { get; set; }

    async Task ExportXlsx_Click() {
        await MyTreeList.ExportToXlsxAsync("ExportResult", new TreeListXlExportOptions() {
            CustomizeSheet = OnCustomizeSheet
        });
    }
    void OnCustomizeSheet(TreeListExportCustomizeSheetEventArgs args) {
        // Enable auto filter for columns with data
        var positionStart = new DevExpress.Export.Xl.XlCellPosition(0, 0);
        var positionEnd = new DevExpress.Export.Xl.XlCellPosition(MyTreeList.GetDataColumns().Count-1, 0);
        args.Sheet.AutoFilterRange = new DevExpress.Export.Xl.XlCellRange(positionStart, positionEnd);
    }
}
See Also