asposecells.api

Class TableStyle

Represents the table style.

Example:

workbook = Workbook()
firstColumnStyle = workbook.createStyle()
firstColumnStyle.setPattern(BackgroundType.SOLID)
firstColumnStyle.setBackgroundColor(Color.getRed())

lastColumnStyle = workbook.createStyle()
lastColumnStyle.getFont().setBold(True)
lastColumnStyle.setPattern(BackgroundType.SOLID)
lastColumnStyle.setBackgroundColor(Color.getRed())
tableStyleName = "Custom1"
tableStyles = workbook.getWorksheets().getTableStyles()
index1 = tableStyles.addTableStyle(tableStyleName)
tableStyle = tableStyles.get(index1)
elements = tableStyle.getTableStyleElements()
index1 = elements.add(jpype.JInt(TableStyleElementType.FIRST_COLUMN))
element = elements.get(index1)
element.setElementStyle(firstColumnStyle)
index1 = elements.add(jpype.JInt(TableStyleElementType.LAST_COLUMN.value))
element = elements.get(index1)
element.setElementStyle(lastColumnStyle)
cells = workbook.getWorksheets().get(0).getCells()
for i in range(0, 5):
    cells.get(0, i).putValue(CellsHelper.columnIndexToName(i))
for row in range(1, 10):
    for column in range(0, 5):
        cells.get(row, column).putValue(row * column)
tables = workbook.getWorksheets().get(0).getListObjects()
index = tables.add(0, 0, 9, 4, True)
table = tables.get(0)
table.setShowTableStyleFirstColumn(True)
table.setShowTableStyleLastColumn(True)
table.setTableStyleName(tableStyleName)
workbook.save("Book1.xlsx")

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