[]
        
(Showing Draft Content)

GrapeCity.Documents.Excel.ITableColumns.Add

Add Method

Add(int)

Adds a new column to the table and returns the created ITableColumn.

If position is -1 or omitted, the column is appended to the end of the table; otherwise, it is inserted at the specified zero-based position.

Declaration
ITableColumn Add(int position = -1)
Function Add(Optional position As Integer = -1) As ITableColumn
Parameters
Type Name Description
int position

The zero-based position at which to insert the column, or -1 to append it to the end of the table.

Returns
Type Description
ITableColumn

The ITableColumn created at the specified position, or at the end of the table when position is -1 or omitted.

Examples
worksheet.Range["A1:B3"].Value = new object[,] {
    {"Name", "Score"},
    {"Alice", 90},
    {"Bob", 85}
};
ITable table = worksheet.Tables.Add(worksheet.Range["A1:B3"], true);
ITableColumn column = table.Columns.Add();
column.Name = "Region";

Add(int, int)

Adds one or more columns to the table at the specified relative position.

The position is zero-based. Existing columns at the specified position are shifted outward to make room for the new columns.

Declaration
void Add(int position, int count)
Sub Add(position As Integer, count As Integer)
Parameters
Type Name Description
int position

The zero-based relative position at which to add the new column(s). Existing columns at this position are shifted outward.

int count

The number of columns to add.

Examples
worksheet.Range["A1:B3"].Value = new object[,] {
    {"Name", "Score"},
    {"Alice", 90},
    {"Bob", 85}
};
ITable table = worksheet.Tables.Add(worksheet.Range["A1:B3"], true);
table.Columns.Add(1, 2);