TableStyle

TableStyle class

Represents the table style.

class TableStyle;

Example

const { Workbook, BackgroundType, Color, TableStyleElementType, CellsHelper } = require("aspose.cells.node");

var workbook = new Workbook();
var firstColumnStyle = workbook.createStyle();
firstColumnStyle.setPattern(BackgroundType.Solid);
firstColumnStyle.setBackgroundColor(Color.Red);

var lastColumnStyle = workbook.createStyle();
lastColumnStyle.getFont().setIsBold(true);
lastColumnStyle.setPattern(BackgroundType.Solid);
lastColumnStyle.setBackgroundColor(Color.Red);
var tableStyleName = "Custom1";
var tableStyles = workbook.getWorksheets().getTableStyles();
var index1 = tableStyles.addTableStyle(tableStyleName);
var tableStyle = tableStyles.get(index1);
var elements = tableStyle.getTableStyleElements();
index1 = elements.add(TableStyleElementType.FirstColumn);
var element = elements.get(index1);
element.setElementStyle(firstColumnStyle);
index1 = elements.add(TableStyleElementType.LastColumn);
element = elements.get(index1);
element.setElementStyle(lastColumnStyle);
var cells = workbook.getWorksheets().get(0).getCells();
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.getWorksheets().get(0).getListObjects();
var index = tables.add(0, 0, 9, 4, true);
var table = tables.get(0);
table.setShowTableStyleFirstColumn(true);
table.setShowTableStyleLastColumn(true);
table.setTableStyleName(tableStyleName);
workbook.save("output/TablesTableStyle.xlsx");

Methods

MethodDescription
getName()Gets the name of table style.
getTableStyleElements()Gets all elements of the table style.
isNull()Checks whether the implementation object is null.

getName()

Gets the name of table style.

getName() : string;

getTableStyleElements()

Gets all elements of the table style.

getTableStyleElements() : TableStyleElementCollection;

Returns

TableStyleElementCollection

isNull()

Checks whether the implementation object is null.

isNull() : boolean;