Version

FormatAsTable(Boolean) Method

Formats the region as a table and adds an associated WorksheetTable to the Worksheet.Tables collection.
Syntax
public WorksheetTable FormatAsTable( 
   bool tableHasHeaders
)

Parameters

tableHasHeaders
A value which indicates whether the top row of the region contains the headers for the table.

Return Value

The WorksheetTable created the represent the formatted table for the region.
Exceptions
ExceptionDescription
System.InvalidOperationExceptionThe region contains one or more cells from another WorksheetTable.
System.InvalidOperationExceptionThe region contains one or more cells which have a multi-cell ArrayFormula applied.
System.InvalidOperationExceptionThe region contains one or more cells which are part of a WorksheetDataTable.
Remarks

When the table is created, the Workbook.DefaultTableStyle will be applied to the value.

When the table is created, the column names will be taken from the cells in the header row if tableHasHeaders is True. If it is False, the column names will be generated and the cells for the header row will be inserted into the worksheet.

The column names are unique within the owning WorksheetTable. If, when the table is created, there are two or more columns with the same name, the second and subsequent duplicate column names will have a number appended to make them unique. If any cells in the header row have a non-string value, their value will be changed to a string (the current display text of the cell). If any cells in the header row have no value, they will be given a generated column name.

If the region partially contains any merged cell regions, they will be removed from the worksheet and the table region will be expanded to include all cells from the merged region.

Requirements

Target Platforms: Android 4.4+, iOS 8+

Development Environments: Visual Studio 2015+, Visual Studio for Mac Preview, Xamarin for Visual Studio 4.2+

See Also