Skip to main content

GridXlExportOptions.ExportUnboundExpressionAsFunction Property

Specifies whether the grid exports an unbound column expression as a function or as a result value.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.2.dll

NuGet Package: DevExpress.Blazor

Declaration

[DefaultValue(false)]
public bool ExportUnboundExpressionAsFunction { get; set; }

Property Value

Type Default Description
Boolean false

true, to export an unbound expression as a function; false, to export an unbound expression as a result value.

Remarks

If a grid contains an unbound column whose values are evaluated based on the UnboundExpression property, the component exports the column’s cells as result values. Set the ExportUnboundExpressionAsFunction property to true to export the column values as functions.

View Example: Customize Export Settings

To export an expression that is based on the values of other columns, these columns must also be exported. Otherwise, the unbound column values are exported as result values regardless of the ExportUnboundExpressionAsFunction property value.

A limited number of functions is supported when exporting expressions. See the following topic for more information: Criteria Language Syntax.

<DxGrid @ref="Grid" Data="@Data">
    <Columns>
        <DxGridDataColumn FieldName="CompanyName" />
        <DxGridDataColumn FieldName="City" ExportWidth="120" />
        <DxGridDataColumn FieldName="Country" ExportWidth="120" />
        <DxGridDataColumn FieldName="UnitPrice" DisplayFormat="c" ExportWidth="70"/>
        <DxGridDataColumn FieldName="Quantity" ExportWidth="70" />
        <DxGridDataColumn FieldName="Total" UnboundType="GridUnboundColumnType.Decimal" 
                          DisplayFormat="c" ExportWidth="70"
                          UnboundExpression="[UnitPrice] * [Quantity]" />
    </Columns>
</DxGrid>
<DxButton Text="Export to XLSX" Click="ExportXlsx_Click" />
@code {
    IEnumerable<object> Data { get; set; }
    IGrid Grid { get; set; }
    protected override async Task OnInitializedAsync() {
        var invoices = await NwindDataService.GetInvoicesAsync();
        var customers = await NwindDataService.GetCustomersAsync();
        Data = invoices.OrderBy(i => i.OrderDate).Join(customers, i => i.CustomerId, c => c.CustomerId, (i, c) => {
            return new {
                CompanyName = c.CompanyName,
                City = i.City,
                Region = i.Region,
                Country = i.Country,
                UnitPrice = i.UnitPrice,
                Quantity = i.Quantity
            };
        });
    }
    async Task ExportXlsx_Click() {
        var options = new GridXlExportOptions();
        options.ExportUnboundExpressionAsFunction = true;
        await Grid.ExportToXlsxAsync("ExportResult", options);
    }
}

Grid - Export unbound functions

See Also