Skip to main content

IXlTable.HasHeaderRow Property

Gets a value indicating whether the header row is displayed for the table.

Namespace: DevExpress.Export.Xl

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

NuGet Package: DevExpress.Printing.Core

Declaration

bool HasHeaderRow { get; }

Property Value

Type Description
Boolean

true, if the table has the visible header row; otherwise, false.

Remarks

The HasHeaderRow property value depends on the value of the hasHeaderRow parameter of the IXlRow.BeginTable method. If you choose to display the table’s header row, the corresponding cells containing the names of table columns will be automatically generated. The table header row is highlighted in the following image (the workbook is opened in Microsoft® Excel®).

XlExport_Tables_HeaderRow

The optional headerRowFormatting parameter of the IXlRow.BeginTable method allows you to specify formatting settings for the header row of the table. If the custom formatting for the table header 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 hide the header row for the table. To do this, use the IXlRow.BeginTable method with the hasHeaderRow 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" };

// Create the first row in the worksheet from which the table starts.
using (IXlRow row = sheet.CreateRow())
{
    // Start generating the table with the hidden header row.
    table = row.BeginTable(columnNames, false);
    // Specify the total row label.
    table.Columns[0].TotalRowLabel = "Total";
    // Specify the function to calculate the total.
    table.Columns[2].TotalRowFunction = XlTotalRowFunction.Sum;
    // Populate the first table row with data.
    row.BulkCells(new object[] { "Camembert Pierrot", "Dairy Products", 17000 }, null);
}

// Generate the remaining table rows and populate them with data.
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