Skip to main content
All docs
V25.1
  • TreeListXlExportOptions.CustomizeSheet Property

    Allows you to customize sheet settings in the exported document.

    Namespace: DevExpress.Blazor

    Assembly: DevExpress.Blazor.v25.1.dll

    NuGet Package: DevExpress.Blazor

    Declaration

    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.

    <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