Class ListObject
Namespace: Aspose.Cells.Tables
Assembly: Aspose.Cells.dll (25.2.0)
Represents a list object on a worksheet. The ListObject object is a member of the ListObjects collection. The ListObjects collection contains all the list objects on a worksheet.
public class ListObject
Inheritance
Inherited Members
object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()
Examples
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 <5; 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;
table.ListColumns[4].TotalsCalculation = Aspose.Cells.Tables.TotalsCalculation.Sum;
workbook.Save(@"Book1.xlsx");
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 4
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
table.ListColumns(4).TotalsCalculation = Aspose.Cells.Tables.TotalsCalculation.Sum
workbook.Save("Book1.xlsx")
Properties
AlternativeDescription
Gets and sets the alternative description.
public string AlternativeDescription { get; set; }
Property Value
AlternativeText
Gets and sets the alternative text.
public string AlternativeText { get; set; }
Property Value
AutoFilter
Gets auto filter.
public AutoFilter AutoFilter { get; }
Property Value
Comment
Gets and sets the comment of the table.
public string Comment { get; set; }
Property Value
DataRange
Gets the data range of the ListObject.
public Range DataRange { get; }
Property Value
DataSourceType
Gets the data source type of the table.
public TableDataSourceType DataSourceType { get; }
Property Value
DisplayName
Gets and sets the display name.
public string DisplayName { get; set; }
Property Value
EndColumn
Gets the end column of the range.
public int EndColumn { get; }
Property Value
EndRow
Gets the end row of the range.
public int EndRow { get; }
Property Value
ListColumns
Gets ListColumns of the ListObject.
public ListColumnCollection ListColumns { get; }
Property Value
QueryTable
Gets the linked QueryTable.
public QueryTable QueryTable { get; }
Property Value
ShowHeaderRow
Gets and sets whether this ListObject show header row.
public bool ShowHeaderRow { get; set; }
Property Value
ShowTableStyleColumnStripes
Indicates whether column stripe formatting is applied.
public bool ShowTableStyleColumnStripes { get; set; }
Property Value
ShowTableStyleFirstColumn
Indicates whether the first column in the table should have the style applied.
public bool ShowTableStyleFirstColumn { get; set; }
Property Value
ShowTableStyleLastColumn
Indicates whether the last column in the table should have the style applied.
public bool ShowTableStyleLastColumn { get; set; }
Property Value
ShowTableStyleRowStripes
Indicates whether row stripe formatting is applied.
public bool ShowTableStyleRowStripes { get; set; }
Property Value
ShowTotals
Gets and sets whether this ListObject show total row.
public bool ShowTotals { get; set; }
Property Value
StartColumn
Gets the start column of the range.
public int StartColumn { get; }
Property Value
StartRow
Gets the start row of the range.
public int StartRow { get; }
Property Value
TableStyleName
Gets and sets the table style name.
public string TableStyleName { get; set; }
Property Value
TableStyleType
Gets and the built-in table style.
public TableStyleType TableStyleType { get; set; }
Property Value
Examples
Workbook workbook = new Workbook("Book1.xlsx");
ListObjectCollection tables = workbook.Worksheets[0].ListObjects;
int index = tables.Add(0, 0, 9, 4, true);
ListObject table = tables[0];
table.TableStyleType = TableStyleType.TableStyleDark2;
workbook.Save("TableStyle.xlsx");
Dim workbook As Workbook = New Workbook("Book1.xlsx")
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.TableStyleType = TableStyleType.TableStyleDark2;
workbook.Save("Book1.xlsx")
XmlMap
Gets an Aspose.Cells.Tables.ListObject.XmlMap used for this list.
public XmlMap XmlMap { get; }
Property Value
Methods
ApplyStyleToRange()
Apply the table style to the range.
public void ApplyStyleToRange()
ConvertToRange()
Convert the table to range.
public void ConvertToRange()
ConvertToRange(TableToRangeOptions)
Convert the table to range.
public void ConvertToRange(TableToRangeOptions options)
Parameters
options
TableToRangeOptions
the options when converting table to range.
Filter()
Filter the table.
public AutoFilter Filter()
Returns
PutCellFormula(int, int, string)
Put the formula to the cell in the table.
public void PutCellFormula(int rowOffset, int columnOffset, string formula)
Parameters
rowOffset
int
The row offset in the table.
columnOffset
int
The column offset in the table.
formula
string
The formula of the cell.
PutCellFormula(int, int, string, bool)
Put the formula to the cell in the table.
public void PutCellFormula(int rowOffset, int columnOffset, string formula, bool isTotalsRowFormula)
Parameters
rowOffset
int
The row offset in the table.
columnOffset
int
The column offset in the table.
formula
string
The formula of the cell.
isTotalsRowFormula
bool
PutCellValue(int, int, object)
Put the value to the cell.
public void PutCellValue(int rowOffset, int columnOffset, object value)
Parameters
rowOffset
int
The row offset in the table.
columnOffset
int
The column offset in the table.
value
object
The cell value.
PutCellValue(int, int, object, bool)
Put the value to the cell.
public void PutCellValue(int rowOffset, int columnOffset, object value, bool isTotalsRowLabel)
Parameters
rowOffset
int
The row offset in the table.
columnOffset
int
The column offset in the table.
value
object
The cell value.
isTotalsRowLabel
bool
Indicates whether it is a label for total row,only works for total row. If False and this row is total row, a new row will be inserted.
Resize(int, int, int, int, bool)
Resize the range of the list object.
public void Resize(int startRow, int startColumn, int endRow, int endColumn, bool hasHeaders)
Parameters
startRow
int
The start row index of the new range.
startColumn
int
The start column index of the new range.
endRow
int
The end row index of the new range.
endColumn
int
The end column index of the new range.
hasHeaders
bool
Whether this table has headers.
UpdateColumnName()
Updates all list columns’ name from the worksheet.
public void UpdateColumnName()
Remarks
The value of the cells in the header row of the table must be same as the name of the ListColumn; Cell.PutValue do not auto modify the name of the ListColumn for performance.