com.aspose.cells
Class TableStyle

java.lang.Object
    extended by com.aspose.cells.TableStyle

public class TableStyle 
extends java.lang.Object

Represents the table style.

Example:

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

Style lastColumnStyle = workbook.createStyle();
lastColumnStyle.getFont().setBold(true);
lastColumnStyle.setPattern(BackgroundType.SOLID);
lastColumnStyle.setBackgroundColor(com.aspose.cells.Color.getRed());
String tableStyleName = "Custom1";
TableStyleCollection tableStyles = workbook.getWorksheets().getTableStyles();
int index1 = tableStyles.addTableStyle(tableStyleName);
TableStyle tableStyle = tableStyles.get(index1);
TableStyleElementCollection elements = tableStyle.getTableStyleElements();
index1 = elements.add(TableStyleElementType.FIRST_COLUMN);
TableStyleElement element = elements.get(index1);
element.setElementStyle(firstColumnStyle);
index1 = elements.add(TableStyleElementType.LAST_COLUMN);
element = elements.get(index1);
element.setElementStyle(lastColumnStyle);
Cells cells = workbook.getWorksheets().get(0).getCells();
for (int i = 0; i < 5; i++)
{
    cells.get(0, i).putValue(CellsHelper.columnIndexToName(i));
}
for (int row = 1; row < 10; row++)
{
    for (int column = 0; column < 5; column++)
    {
        cells.get(row, column).putValue(row * column);
    }
 }
ListObjectCollection tables = workbook.getWorksheets().get(0).getListObjects();
int index = tables.add(0, 0, 9, 4, true);
ListObject table = tables.get(0);
table.setShowTableStyleFirstColumn(true);
table.setShowTableStyleLastColumn(true);
table.setTableStyleName(tableStyleName);
workbook.save("C:\\Book1.xlsx");

Property Getters/Setters Summary
java.lang.StringgetName()
           Gets the name of table style.
TableStyleElementCollectiongetTableStyleElements()
           Gets all elements of the table style.
 

Property Getters/Setters Detail

getName

public java.lang.String getName()
Gets the name of table style.

getTableStyleElements

public TableStyleElementCollection getTableStyleElements()
Gets all elements of the table style.

See Also:
          Aspose.Cells Documentation - the home page for the Aspose.Cellss Product Documentation.
          Aspose.Cells Support Forum - our preferred method of support.