DxTreeListDataColumn.ExportWidth Property
Specifies the column’s export width in pixels.
Namespace: DevExpress.Blazor
Assembly: DevExpress.Blazor.v25.1.dll
NuGet Package: DevExpress.Blazor
Declaration
[DefaultValue(200)]
[Parameter]
public int ExportWidth { get; set; }
Property Value
Type | Default | Description |
---|---|---|
Int32 | 200 | The column width. |
Remarks
When you export data to Excel formats (XLS and XLSX) or PDF, use the ExportWidth
property to specify the width of the column in the exported document.
Export to Excel Formats
Note that Microsoft Excel performs width calculation in characters. When you open a document, Excel converts the column width in pixels to characters. The column width in characters differs on a machine with more than 100% DPI - the resulting width in pixels differs from the specified value. You can handle the CustomizeColumn action and specify the Column.WidthInCharacters property to set the column width in characters.
The following example applies the ExportWidth
property to the Task column:
<DxTreeList Data="TreeListData" KeyFieldName="Id" ParentKeyFieldName="ParentId">
<Columns>
<DxTreeListDataColumn FieldName="Name" Caption="Task" ExportWidth="300" />
<DxTreeListDataColumn FieldName="EmployeeName" />
<DxTreeListDataColumn FieldName="StartDate" />
<DxTreeListDataColumn FieldName="DueDate" />
</Columns>
</DxTreeList>
For more information about data export in the TreeList component, refer to the following topic: Export Data in Blazor TreeList.
Export to PDF
When exporting to PDF, the TreeList component recalculates column widths so that the output table occupies all available space. Disable the FitToPage export option to use the exact ExportWidth
values for exported columns. If a page does not have enough space to render a column, then this and subsequent columns are moved to the next page (similar to the Summary column in the image below).
You can also handle the CustomizeColumn event and specify the Width event argument to modify the export width.
The following example exports TreeList data to PDF. Columns in the exported document have the following widths:
- Name - 300 pixels
- Type - 200 pixels (default)
- Mass, kg and Radius, km - 350 pixels
@rendermode InteractiveServer
@using DevExpress.Drawing
@inject SpaceObjectDataProvider SpaceObjectDataProvider
<DxTreeList @ref="TreeList" Data="TreeListData" ChildrenFieldName="Satellites">
<Columns>
<DxTreeListDataColumn FieldName="Name" ExportWidth="300" />
<DxTreeListDataColumn FieldName="TypeOfObject" Caption="Type" />
<DxTreeListDataColumn FieldName="Mass10pow21kg" Caption="Mass, kg" ExportWidth="350" DisplayFormat="N2" />
<DxTreeListDataColumn FieldName="MeanRadiusInKM" Caption="Radius, km" ExportWidth="350" DisplayFormat="N2" />
</Columns>
<ToolbarTemplate>
<DxToolbar>
<DxToolbarItem Text="Export to PDF" Click="ExportPdf_Click" BeginGroup="true" />
</DxToolbar>
</ToolbarTemplate>
</DxTreeList>
@code {
ITreeList TreeList { get; set; }
object TreeListData { get; set; }
protected override async Task OnInitializedAsync() {
TreeListData = SpaceObjectDataProvider.GenerateData();
}
async Task ExportPdf_Click() {
await TreeList.ExportToPdfAsync("ExportResult", new TreeListPdfExportOptions() {
FitToPage = false,
CustomizeDocument = args => {
args.PaperKind = DevExpress.Drawing.Printing.DXPaperKind.A6;
args.Margins = new DXMargins(50, 50, 50, 50);
},
});
}
}