Skip to main content

IXlTableColumn.TotalRowFormatting Property

Gets or sets format characteristics for the total row cell of the table column.

Namespace: DevExpress.Export.Xl

Assembly: DevExpress.Printing.v24.2.Core.dll

Declaration

XlDifferentialFormatting TotalRowFormatting { get; set; }

Property Value

Type Description
DevExpress.Export.Xl.XlDifferentialFormatting

An XlDifferentialFormatting instance that specifies format characteristics applied to the column’s total cell.

Remarks

Use the TotalRowFormatting property to apply custom formatting to the total row cell of the table column. In particular, you can color the cell background, adjust font settings, align the cell content, add borders and specify number format options. To do this, use properties of the XlDifferentialFormatting object inherited from the XlFormatting class: XlFormatting.Fill, XlFormatting.Font, XlFormatting.Alignment, XlFormatting.Border and XlFormatting.NumberFormat. Moreover, the XlDifferentialFormatting object implements implicit conversion from the XlFill, XlFont, XlCellAlignment, XlBorder and XlNumberFormat objects, so that you can directly assign an object containing the required format settings to the TotalRowFormatting property without using unnecessary cast operators.

To apply custom formatting to the data area of the table column, use the IXlTableColumn.DataFormatting property.

For more information on how to set custom formatting for different table regions and individual table columns, refer to the How to: Apply Custom Formatting to a Table example.

Example

Note

A complete sample project is available at https://github.com/DevExpress-Examples/excel-export-api-examples

IXlTable table;
// Specify an array containing column headings for a table.
string[] columnNames = new string[] { "Product", "Category", "Amount" };

// Create the first row in the worksheet from which the table starts.
using (IXlRow row = sheet.CreateRow())
{
    // Start generating the table with a header row displayed.
    table = row.BeginTable(columnNames, true);
    // Specify the total row label.
    table.Columns[0].TotalRowLabel = "Total";
    // Specify the function to calculate the total.
    table.Columns[2].TotalRowFunction = XlTotalRowFunction.Sum;
    // Specify the number format for the "Amount" column and its total cell.
    XlNumberFormat accounting = @"_([$$-409]* #,##0.00_);_([$$-409]* \(#,##0.00\);_([$$-409]* ""-""??_);_(@_)";
    table.Columns[2].DataFormatting = accounting;
    table.Columns[2].TotalRowFormatting = accounting;
}

// Generate table rows and populate them with data.
using (IXlRow row = sheet.CreateRow())
    row.BulkCells(new object[] { "Camembert Pierrot", "Dairy Products", 17000 }, null);
using (IXlRow row = sheet.CreateRow())
    row.BulkCells(new object[] { "Gnocchi di nonna Alice", "Grains/Cereals", 15500 }, null);
using (IXlRow row = sheet.CreateRow())
    row.BulkCells(new object[] { "Mascarpone Fabioli", "Dairy Products", 15000 }, null);
using (IXlRow row = sheet.CreateRow())
    row.BulkCells(new object[] { "Ravioli Angelo", "Grains/Cereals", 12500 }, null);

// Create the total row and finish the table.
using (IXlRow row = sheet.CreateRow())
    row.EndTable(table, true);
See Also