Table of Contents

Interface IListObjectColumn

Namespace
Spire.Xls.Core
Assembly
Spire.XLS.dll

Represents a column in the table.

public interface IListObjectColumn

Properties

CalculatedFormula

Gets or sets calculated formula value. The following code illustrates how to set a formula to third column to hold the sum of first and second column's data:

//Create worksheet
Workbook workbook = new Workbook();
workbook.LoadFromFile("Sample.xlsx");
Worksheet worksheet = workbook.Worksheets[0];

//Create table
IListObject table1 = worksheet.ListObjects.Create("Table1", worksheet["A1:C6"]);

//Total row
table1.ShowTotals = true;
table1.Columns[0].TotalsRowLabel = "Total";
table1.Columns[1].TotalsCalculation = ExcelTotalsCalculation.Sum;
table1.Columns[2].TotalsCalculation = ExcelTotalsCalculation.Sum;

//Save to file
workbook.SaveToFile("Table.xlsx");
string CalculatedFormula { get; set; }

Property Value

string

Id

Gets column id of current column. Read-only. The following code illustrates how create table using the data in the range "A1:C6" and print first column's name,id and index:

//Create worksheet
Workbook workbook = new Workbook();
workbook.LoadFromFile("Sample.xlsx");
Worksheet worksheet = workbook.Worksheets[0];

//Create table
IListObject table1 = worksheet.ListObjects.Create("Table1", worksheet["A1:C6"]);

//Print Column Name, ID, Index
Console.WriteLine("Column Name " + table1.Columns[0].Name);
Console.WriteLine("Column ID " + table1.Columns[0].Id);
Console.WriteLine("Column Index " + table1.Columns[0].Index);

//Save to file
workbook.SaveToFile("Table.xlsx");
int Id { get; }

Property Value

int

Index

Gets column index. The following code illustrates how create table using the data in the range "A1:C6" and print first column's name,id and index:

//Create worksheet
Workbook workbook = new Workbook();
workbook.LoadFromFile("Sample.xlsx");
Worksheet worksheet = workbook.Worksheets[0];

//Create table
IListObject table1 = worksheet.ListObjects.Create("Table1", worksheet["A1:C6"]);

//Print Column Name, ID, Index
Console.WriteLine("Column Name " + table1.Columns[0].Name);
Console.WriteLine("Column ID " + table1.Columns[0].Id);
Console.WriteLine("Column Index " + table1.Columns[0].Index);

//Save to file
workbook.SaveToFile("Table.xlsx");
int Index { get; }

Property Value

int

Name

Gets or sets name of the column. The following code illustrates how create table using the data in the range "A1:C6" and print first column's name,id and index:

//Create worksheet
Workbook workbook = new Workbook();
workbook.LoadFromFile("Sample.xlsx");
Worksheet worksheet = workbook.Worksheets[0];

//Create table
IListObject table1 = worksheet.ListObjects.Create("Table1", worksheet["A1:C6"]);

//Print Column Name, ID, Index
Console.WriteLine("Column Name " + table1.Columns[0].Name);
Console.WriteLine("Column ID " + table1.Columns[0].Id);
Console.WriteLine("Column Index " + table1.Columns[0].Index);

//Save to file
workbook.SaveToFile("Table.xlsx");
string Name { get; set; }

Property Value

string

TotalsCalculation

Gets or sets function used for totals calculation. The following code illustrates how to set IListObject.ShowTotals to "True" to enable totals and set ExcelTotalsCalculation.Sum for second and third columns to get sum of values in the respective columns:

//Create worksheet
Workbook workbook = new Workbook();
workbook.LoadFromFile("Sample.xlsx");
Worksheet worksheet = workbook.Worksheets[0];

//Create table
IListObject table1 = worksheet.ListObjects.Create("Table1", worksheet["A1:C6"]);

//Total row
table1.ShowTotals = true;
table1.Columns[0].TotalsRowLabel = "Total";
table1.Columns[1].TotalsCalculation = ExcelTotalsCalculation.Sum;
table1.Columns[2].TotalsCalculation = ExcelTotalsCalculation.Sum;

//Save to file
workbook.SaveToFile("Table.xlsx");
ExcelTotalsCalculation TotalsCalculation { get; set; }

Property Value

ExcelTotalsCalculation

TotalsRowLabel

Gets or sets label of the totals row. The following code illustrates how to set a string "Total" to the first column's TotalsRowLabel property to indicate that it's adjacent cell holds sum of the values of it's column:

//Create worksheet
Workbook workbook = new Workbook();
workbook.LoadFromFile("Sample.xlsx");
Worksheet worksheet = workbook.Worksheets[0];

//Create table
IListObject table1 = worksheet.ListObjects.Create("Table1", worksheet["A1:C6"]);

//Total row
table1.ShowTotals = true;
table1.Columns[0].TotalsRowLabel = "Total";
table1.Columns[1].TotalsCalculation = ExcelTotalsCalculation.Sum;
table1.Columns[2].TotalsCalculation = ExcelTotalsCalculation.Sum;

//Save to file
workbook.SaveToFile("Table.xlsx");
string TotalsRowLabel { get; set; }

Property Value

string