[]
An ITableStyle can be a built-in style or a custom style stored in the workbook. Use this interface to access the style name, inspect whether the style is built in, and modify its ITableStyleElements before applying it to a table.
ITableStyle tableStyle = workbook.getTableStyles().get("TableStyleLight11");
worksheet.getTables().add(worksheet.getRange("A1:B3"), true);
worksheet.getTables().get(0).setTableStyle(tableStyle);
voiddelete()ITableStyle object.ITableStyle object and returns a reference to the new copy.ITableStyle object with the specified name.getName()booleanbooleanbooleanITableStyleElements object.booleanvoidsetShowAsAvailablePivotStyle(boolean value) voidsetShowAsAvailableSlicerStyle(boolean value) voidsetShowAsAvailableTableStyle(boolean value)
ITableStyle tableStyle = workbook.getTableStyles().get("TableStyleLight11");
boolean builtIn = tableStyle.isBuiltIn();
ITableStyle tableStyle = workbook.getTableStyles().get("TableStyleLight11");
String name = tableStyle.getName();
ITableStyleElements object.
ITableStyle tableStyle = workbook.getTableStyles().get("TableStyleLight11");
ITableStyleElements elements = tableStyle.getTableStyleElements();
ITableStyleElements.ITableStyle object.
ITableStyle tableStyle = workbook.getTableStyles().add("TemporaryTableStyle");
tableStyle.delete();
ITableStyle object and returns a reference to the new copy.
ITableStyle sourceStyle = workbook.getTableStyles().get("TableStyleLight11");
ITableStyle copiedStyle = sourceStyle.duplicate();
ITableStyle object.ITableStyle object with the specified name. If newName is null, this method forwards the current style name to the duplication logic. If the specified name already exists, a valid style name is generated for the new copy.
ITableStyle sourceStyle = workbook.getTableStyles().get("TableStyleLight11");
ITableStyle copiedStyle = sourceStyle.duplicate("CustomLightStyle");
worksheet.getRange("A1:B3").setValue(new Object[][] {
{"Name", "Value"},
{"Test", 100}
});
worksheet.getTables().add(worksheet.getRange("A1:B3"), true).setTableStyle(copiedStyle);
newName - The name of the new table style. May be null.ITableStyle object with the specified name.
ITableStyle slicerStyle = workbook.getTableStyles().add("CustomSlicerStyle");
slicerStyle.setShowAsAvailableSlicerStyle(true);
boolean available = slicerStyle.getShowAsAvailableSlicerStyle();
Set this property to true to mark a custom table style as a slicer style so it can be used for slicers. When set to true, this style is no longer marked as available in the table or pivot style galleries.
ITableStyle slicerStyle = workbook.getTableStyles().add("CustomSlicerStyle");
slicerStyle.setShowAsAvailableSlicerStyle(true);
value - true to show this table style as available in the slicer styles gallery; otherwise, false.
ITableStyle tableStyle = workbook.getTableStyles().add("CustomTableStyle");
tableStyle.setShowAsAvailableTableStyle(true);
boolean available = tableStyle.getShowAsAvailableTableStyle();
Set this property to true to make the style available for tables. When this property is set to true, the style is no longer marked as available in the pivot styles gallery or the slicer styles gallery.
ITableStyle tableStyle = workbook.getTableStyles().add("CustomTableStyle");
tableStyle.setShowAsAvailableTableStyle(true);
worksheet.getRange("A1:B3").setValue(new Object[][] {
{"Name", "Value"},
{"Test", 100}
});
worksheet.getTables().add(worksheet.getRange("A1:B3"), true).setTableStyle(tableStyle);
value - true to show this style as available in the table styles gallery; false to hide it from the gallery.
ITableStyle pivotStyle = workbook.getTableStyles().add("CustomPivotStyle");
pivotStyle.setShowAsAvailablePivotStyle(true);
boolean available = pivotStyle.getShowAsAvailablePivotStyle();
Set this property to true to make the style available for pivot tables. A pivot table style must be marked as available before it can be applied through IPivotTable.setStyle(ITableStyle).
worksheet.getRange("A1:B4").setValue(new Object[][] {
{"Name", "Amount"},
{"A", 100},
{"B", 200},
{"A", 150}
});
ITableStyle style = workbook.getTableStyles().add("CustomPivotStyle");
style.setShowAsAvailablePivotStyle(true);
IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:B4"));
IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("D1"), "SalesPivot");
pivotTable.setStyle(style);
value - true to show this style as available in the pivot styles gallery; false to hide it from the gallery.