ListColumn

ListColumn class

表示列表中的一列。

public class ListColumn

特性

姓名描述
Formula { get; set; }获取和设置列表列的公式。
Name { get; set; }获取和设置列的名称。
Range { get; }获取此列表列的范围。
TotalsCalculation { get; set; }获取和设置列表列的 Totals 行中的计算类型。

方法

姓名描述
GetCustomCalculatedFormula(bool, bool)获取此列表列的公式。
GetCustomTotalsRowFormula(bool, bool)获取此列表列的总计行的公式。
SetCustomCalculatedFormula(string, bool, bool)设置此列表列的公式。
SetCustomTotalsRowFormula(string, bool, bool)获取此列表列的总计行的公式。

例子


[C#]


Workbook workbook = new Workbook();
Cells cells = workbook.Worksheets[0].Cells;
for (int i = 0; i  <5; i++)
{
cells[0,i].PutValue(CellsHelper.ColumnIndexToName(i));
 }
for (int row = 1; row  <10; row++)
{
 for (int column = 0; column  <4; column++)
{
cells[row, column].PutValue(row * column);
 }
 }
ListObjectCollection tables = workbook.Worksheets[0].ListObjects;
int index = tables.Add(0, 0, 9, 4, true);
ListObject table = tables[0];
table.ShowTotals = true;
ListColumn listColumn = table.ListColumns[4];
listColumn.TotalsCalculation = Aspose.Cells.Tables.TotalsCalculation.Sum;
listColumn.Formula = "=[A]";
workbook.Save(@"Book1.xlsx");


[Visual Basic]

Dim workbook As Workbook = New Workbook()
Dim cells As Cells = workbook.Worksheets(0).Cells
For i As Int32 = 0 To 4
 cells(0, i).PutValue(CellsHelper.ColumnIndexToName(i))
Next
For row As Int32 = 1 To 9
 For column As Int32 = 0 To 3
  cells(row, column).PutValue(row * column)
Next
Next
Dim tables As ListObjectCollection = workbook.Worksheets(0).ListObjects
Dim index As Int32 = tables.Add(0, 0, 9, 4, True)
Dim table As ListObject = tables(0)
table.ShowTotals = True
Dim listColumn as ListColumn = table.ListColumns(4);
listColumn.TotalsCalculation = Aspose.Cells.Tables.TotalsCalculation.Sum;
listColumn.Formula = "=[A]";
workbook.Save("Book1.xlsx")

也可以看看