public class TableStyle
extends java.lang.Object
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 ɝ i++)
{
cells.get(0, i).putValue(CellsHelper.columnIndexToName(i));
}
for (int row = 1; row row++)
{
for (int column = 0; column ɝ 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("Book1.xlsx");
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
getName()
Gets the name of table style.
|
TableStyleElementCollection |
getTableStyleElements()
Gets all elements of the table style.
|
public java.lang.String getName()
public TableStyleElementCollection getTableStyleElements()
See Also:
Aspose.Cells Documentation - the home page for the Aspose.Cells Product Documentation.
Aspose.Cells Support Forum - our preferred method of support.
We guarantee a prompt response to any inquiry!
© Aspose Pty Ltd 2003-2025. All Rights Reserved.