Skip to content

FormatAsTable.cs

Avrigeanu Laurian edited this page Apr 12, 2023 · 1 revision

FormatAsTable(object sheet, string range, string tableName, bool hasHeaders)

Parameters

  • sheet: Object. The Excel worksheet to format.
  • range: String. The range of cells to format as a table.
  • tableName: String. The name of the table to create.
  • hasHeaders: Boolean. A flag indicating whether the table has headers.

Returns

This method does not return anything.

Remarks

This method formats a range of cells as an Excel table. It takes in the worksheet to format, the range of cells to format, the name of the table to create, and a flag indicating whether the table has headers.

The table object is created using the ListObjects.Add method, which takes in the range of cells, the source type, whether to include column headers, and other optional parameters. The method then sets the name of the table and, if hasHeaders is true, sets the color of the header row.

Finally, the method releases the COM objects used in the process to avoid memory leaks.

Clone this wiki locally