ListObject

ListObject class

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.

class ListObject;

Example

const { Workbook, CellsHelper, TotalsCalculation, SaveFormat } = AsposeCells;

var workbook = new Workbook();
var cells = workbook.worksheets.get(0).cells;
for (var i = 0; i < 5; i++) {
    cells.get(0, i).putValue(CellsHelper.columnIndexToName(i));
}
for (var row = 1; row < 10; row++) {
    for (var column = 0; column < 5; column++) {
        cells.get(row, column).putValue(row * column);
    }
}
var tables = workbook.worksheets.get(0).getListObjects();
var index = tables.add(0, 0, 9, 4, true);
var table = tables.get(0);
table.showTotals = true;
table.listColumns.get(4).totalsCalculation = TotalsCalculation.Sum;
var uint8Array = workbook.save(SaveFormat.Xlsx);

Properties

PropertyTypeDescription
startRownumberReadonly. Gets the start row of the range.
startColumnnumberReadonly. Gets the start column of the range.
endRownumberReadonly. Gets the end row of the range.
endColumnnumberReadonly. Gets the end column of the range.
listColumnsListColumnCollectionReadonly. Gets ListColumns of the ListObject.
showHeaderRowbooleanGets and sets whether this ListObject show header row.
showTotalsbooleanGets and sets whether this ListObject show total row.
dataRangeRangeReadonly. Gets the data range of the ListObject.
queryTableQueryTableReadonly. Gets the linked QueryTable.
dataSourceTypeTableDataSourceTypeReadonly. Gets the data source type of the table.
autoFilterAutoFilterReadonly. Gets auto filter.
displayNamestringGets and sets the display name.
commentstringGets and sets the comment of the table.
showTableStyleFirstColumnbooleanIndicates whether the first column in the table should have the style applied.
showTableStyleLastColumnbooleanIndicates whether the last column in the table should have the style applied.
showTableStyleRowStripesbooleanIndicates whether row stripe formatting is applied.
showTableStyleColumnStripesbooleanIndicates whether column stripe formatting is applied.
tableStyleTypeTableStyleTypeGets and the built-in table style.
tableStyleNamestringGets and sets the table style name.
xmlMapXmlMapReadonly. Gets an XmlMap used for this list.
alternativeTextstringGets and sets the alternative text.
alternativeDescriptionstringGets and sets the alternative description.

Methods

MethodDescription
resize(number, number, number, number, boolean)Resize the range of the list object.
putCellValue(number, number, VObject)Put the value to the cell.
putCellValue(number, number, VObject, boolean)Put the value to the cell.
putCellFormula(number, number, string)Put the formula to the cell in the table.
putCellFormula(number, number, string, boolean)Put the formula to the cell in the table.
updateColumnName()Updates all list columns’ name from the worksheet.
filter()Filter the table.
applyStyleToRange()Apply the table style to the range.
convertToRange()Convert the table to range.
convertToRange(TableToRangeOptions)Convert the table to range.

startRow

Readonly. Gets the start row of the range.

startRow : number;

startColumn

Readonly. Gets the start column of the range.

startColumn : number;

endRow

Readonly. Gets the end row of the range.

endRow : number;

endColumn

Readonly. Gets the end column of the range.

endColumn : number;

listColumns

Readonly. Gets ListColumns of the ListObject.

listColumns : ListColumnCollection;

showHeaderRow

Gets and sets whether this ListObject show header row.

showHeaderRow : boolean;

showTotals

Gets and sets whether this ListObject show total row.

showTotals : boolean;

dataRange

Readonly. Gets the data range of the ListObject.

dataRange : Range;

queryTable

Readonly. Gets the linked QueryTable.

queryTable : QueryTable;

dataSourceType

Readonly. Gets the data source type of the table.

dataSourceType : TableDataSourceType;

autoFilter

Readonly. Gets auto filter.

autoFilter : AutoFilter;

displayName

Gets and sets the display name.

displayName : string;

comment

Gets and sets the comment of the table.

comment : string;

showTableStyleFirstColumn

Indicates whether the first column in the table should have the style applied.

showTableStyleFirstColumn : boolean;

showTableStyleLastColumn

Indicates whether the last column in the table should have the style applied.

showTableStyleLastColumn : boolean;

showTableStyleRowStripes

Indicates whether row stripe formatting is applied.

showTableStyleRowStripes : boolean;

showTableStyleColumnStripes

Indicates whether column stripe formatting is applied.

showTableStyleColumnStripes : boolean;

tableStyleType

Gets and the built-in table style.

tableStyleType : TableStyleType;

tableStyleName

Gets and sets the table style name.

tableStyleName : string;

xmlMap

Readonly. Gets an XmlMap used for this list.

xmlMap : XmlMap;

alternativeText

Gets and sets the alternative text.

alternativeText : string;

alternativeDescription

Gets and sets the alternative description.

alternativeDescription : string;

resize(number, number, number, number, boolean)

Resize the range of the list object.

resize(startRow: number, startColumn: number, endRow: number, endColumn: number, hasHeaders: boolean) : void;

Parameters:

ParameterTypeDescription
startRownumberThe start row index of the new range.
startColumnnumberThe start column index of the new range.
endRownumberThe end row index of the new range.
endColumnnumberThe end column index of the new range.
hasHeadersbooleanWhether this table has headers.

putCellValue(number, number, VObject)

Put the value to the cell.

putCellValue(rowOffset: number, columnOffset: number, value: VObject) : void;

Parameters:

ParameterTypeDescription
rowOffsetnumberThe row offset in the table.
columnOffsetnumberThe column offset in the table.
valueVObjectThe cell value.

putCellValue(number, number, VObject, boolean)

Put the value to the cell.

putCellValue(rowOffset: number, columnOffset: number, value: VObject, isTotalsRowLabel: boolean) : void;

Parameters:

ParameterTypeDescription
rowOffsetnumberThe row offset in the table.
columnOffsetnumberThe column offset in the table.
valueVObjectThe cell value.
isTotalsRowLabelbooleanIndicates 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.

putCellFormula(number, number, string)

Put the formula to the cell in the table.

putCellFormula(rowOffset: number, columnOffset: number, formula: string) : void;

Parameters:

ParameterTypeDescription
rowOffsetnumberThe row offset in the table.
columnOffsetnumberThe column offset in the table.
formulastringThe formula of the cell.

putCellFormula(number, number, string, boolean)

Put the formula to the cell in the table.

putCellFormula(rowOffset: number, columnOffset: number, formula: string, isTotalsRowFormula: boolean) : void;

Parameters:

ParameterTypeDescription
rowOffsetnumberThe row offset in the table.
columnOffsetnumberThe column offset in the table.
formulastringThe formula of the cell.
isTotalsRowFormulaboolean

updateColumnName()

Updates all list columns’ name from the worksheet.

updateColumnName() : void;

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.

filter()

Filter the table.

filter() : AutoFilter;

Returns

AutoFilter

applyStyleToRange()

Apply the table style to the range.

applyStyleToRange() : void;

convertToRange()

Convert the table to range.

convertToRange() : void;

convertToRange(TableToRangeOptions)

Convert the table to range.

convertToRange(options: TableToRangeOptions) : void;

Parameters:

ParameterTypeDescription
optionsTableToRangeOptionsthe options when converting table to range.