GridDocumentExportCustomizeColumnEventArgsBase.DataCellStyle Property
Specifies style settings for data cells in the processed column.
Namespace: DevExpress.Blazor
Assembly: DevExpress.Blazor.v25.1.dll
NuGet Package: DevExpress.Blazor
Declaration
public DocumentExportElementStyle DataCellStyle { get; }
Property Value
Type | Description |
---|---|
DocumentExportElementStyle | Style settings. |
Remarks
The PDF export engine applies different formatting to document elements for visual clarity. For instance, it applies the bold font attribute to column captions and colors them gray. The image below displays standard document formatting:
You can use PDF export options to customize document appearance. Style options are applied in the following order:
Style settings that you assign to the DefaultElementStyle property in the
CustomizeDocument
event handler. These settings affect all elements: table cells, document/page headers and footers.The export engine’s style settings.
Style settings that you assign to the
DataCellStyle
property in theCustomizeColumn
event handler. These settings affect all data cells in the corresponding column.Style settings that you assign to the ElementStyle property in the following event handlers:
CustomizeCell
CustomizeDocumentFooter
CustomizeDocumentHeader
CustomizePageFooter
CustomizePageHeader
These settings affect only the corresponding elements.
Note
Styles applied later have higher priority. For instance, export engine styles override DefaultElementStyle settings.
Grid Example
The following example exports Grid data to PDF and customizes output table appearance:
@rendermode InteractiveServer
@using DevExpress.Drawing;
@inject WeatherForecastService ForecastService
<DxGrid @ref="Grid" Data="@forecasts">
<Columns>
<DxGridDataColumn Caption="Date" FieldName="Date" />
<DxGridDataColumn Caption="Summary" FieldName="Summary" />
<DxGridDataColumn Caption="Temperature (C)" FieldName="TemperatureC" />
<DxGridDataColumn Caption="Temperature (F)" FieldName="TemperatureF" Visible="false" />
</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() {
FitToPage = false,
CustomizeColumn = OnCustomizeColumn,
});
}
void OnCustomizeColumn(GridDocumentExportCustomizeColumnEventArgs args) {
args.Width = 400;
args.IsHidden = false;
if (args.ColumnIndex % 2 == 1)
args.DataCellStyle.BackColor = System.Drawing.Color.LightGray;
if (args.FieldName == "Date")
args.DataCellStyle.Font = new DXFont(args.DataCellStyle.Font, DXFontStyle.Bold);
}
}
TreeList Example
The following example exports TreeList data to PDF and customizes output table appearance:
@rendermode InteractiveServer
@using DevExpress.Drawing
@inject SpaceObjectDataProvider SpaceObjectDataProvider
<DxTreeList @ref="TreeList" Data="TreeListData" ChildrenFieldName="Satellites">
<Columns>
<DxTreeListDataColumn FieldName="Name" />
<DxTreeListDataColumn FieldName="TypeOfObject" Caption="Type" />
<DxTreeListDataColumn FieldName="Mass10pow21kg" Caption="Mass, kg" DisplayFormat="N2" />
<DxTreeListDataColumn FieldName="MeanRadiusInKM" Caption="Radius, km" DisplayFormat="N2" />
<DxTreeListDataColumn FieldName="Volume10pow9KM3" Caption="Volume, km³" DisplayFormat="N2" Visible="false" />
<DxTreeListDataColumn FieldName="SurfaceGravity" Caption="Gravity" DisplayFormat="N2" Visible="false" />
</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,
CustomizeColumn = OnCustomizeColumn,
});
}
void OnCustomizeColumn (TreeListDocumentExportCustomizeColumnEventArgs args) {
args.Width = 300;
args.IsHidden = false;
if (args.ColumnIndex % 2 == 1)
args.DataCellStyle.BackColor = System.Drawing.Color.LightGray;
if (args.FieldName == "Name") {
args.DataCellStyle.Font = new DXFont(args.DataCellStyle.Font, DXFontStyle.Bold);
args.Width = 400;
}
}
}