Skip to main content

IXlTable.HasTotalRow Property

Gets a value indicating whether the total row is displayed at the end of the table.

Namespace: DevExpress.Export.Xl

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

NuGet Package: DevExpress.Printing.Core

Declaration

bool HasTotalRow { get; }

Property Value

Type Description
Boolean

true, if the table total row is visible; otherwise, false.

Remarks

The HasTotalRow property value depends on the value of the hasTotalRow parameter of the IXlRow.EndTable method. If this parameter is true, the total row appears at the end of the table, allowing you to calculate a total for each column in the table. Use the column’s IXlTableColumn.TotalRowFunction property to select one of the predefined functions to calculate the total. To specify the text to be displayed in the total cell of the table column, use the IXlTableColumn.TotalRowLabel property.

The table total row is highlighted in the following image (the workbook is opened in Microsoft® Excel®).

XlExport_Tables_TotalRow

To specify formatting settings for the total row of the table, use the IXlTable.TotalRowFormatting property. If the custom formatting for the total row is not specified, its appearance will be defined by the current table style applied to the table (IXlTableStyleInfo.Name).

The example below demonstrates how to turn off the total row for the table. To do this, populate the last row of the table with the required data and then call the row’s IXlRow.EndTable method with the hasTotalRow parameter set to false.

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" };

// Start generating the table with a header row displayed.
using (IXlRow row = sheet.CreateRow())
{
    table = row.BeginTable(columnNames, true);
}

// 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);

// Create the last table row and finish the table.
// The total row is not displayed for the table. 
using (IXlRow row = sheet.CreateRow())
{
    row.BulkCells(new object[] { "Ravioli Angelo", "Grains/Cereals", 12500 }, null);
    row.EndTable(table, false);
}
See Also