-
Notifications
You must be signed in to change notification settings - Fork 0
FormatAsTable.cs
Avrigeanu Laurian edited this page Apr 12, 2023
·
1 revision
-
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.
This method does not return anything.
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.