aspose.cells

Class TableStyle

Represents the table style.

Example:

var workbook = new aspose.cells.Workbook();
var firstColumnStyle = workbook.createStyle();
firstColumnStyle.setPattern(aspose.cells.BackgroundType.SOLID);
firstColumnStyle.setBackgroundColor(aspose.cells.Color.getRed());

var lastColumnStyle = workbook.createStyle();
lastColumnStyle.getFont().setBold(true);
lastColumnStyle.setPattern(aspose.cells.BackgroundType.SOLID);
lastColumnStyle.setBackgroundColor(aspose.cells.Color.getRed());
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(aspose.cells.TableStyleElementType.FIRST_COLUMN);
var element = elements.get(index1);
element.setElementStyle(firstColumnStyle);
index1 = elements.add(aspose.cells.TableStyleElementType.LAST_COLUMN);
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(aspose.cells.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("Book1.xlsx");

Property Getters/Setters Summary
functiongetName()
Gets the name of table style.
functiongetTableStyleElements()
Gets all elements of the table style.
 

    • Property Getters/Setters Detail

      • getName : String 

        function getName()
        
        Gets the name of table style.