Skip to main content

IXlTableColumn.TotalRowFunction Property

Gets or sets the function to calculate the total of the table column.

Namespace: DevExpress.Export.Xl

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

NuGet Package: DevExpress.Printing.Core

Declaration

XlTotalRowFunction TotalRowFunction { get; set; }

Property Value

Type Description
XlTotalRowFunction

The XlTotalRowFunction enumeration member.

Available values:

Name Description
None

Indicates that the total for the table column is not calculated.

Average

Returns the average (arithmetic mean) of the numbers contained in the table column.

Count

Returns the number of cells with non-empty values contained in the table column.

CountNums

Returns the number of cells with numeric values contained in the table column.

Max

Returns the largest number contained in the table column.

Min

Returns the smallest number contained in the table column.

StdDev

Calculates the standard deviation based on the sample contained in the table column.

Sum

Returns the sum of the numbers contained in the table column.

Var

Calculates the variance of the sample contained in the table column.

Remarks

Use the TotalRowFunction property to select one of the predefined functions to calculate the total for the table column. To specify the text to be displayed in the total cell of the table column, use the IXlTableColumn.TotalRowLabel property.

To display the total row for the table, use the IXlRow.EndTable method with the hasTotalRow parameter set to true. For details on how to generate a table and adjust its properties, refer to the How to: Create 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