[]
        
(Showing Draft Content)

ITableStyle

Interface ITableStyle


public interface ITableStyle
Represents a single style that can be applied to a table.

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);
 
  • Method Details

    • isBuiltIn

      boolean isBuiltIn()
      Gets whether the style is a built-in style.
      
       ITableStyle tableStyle = workbook.getTableStyles().get("TableStyleLight11");
       boolean builtIn = tableStyle.isBuiltIn();
       
      Returns:
      true if the style is a built-in style; otherwise, false.
    • getName

      String getName()
      Gets the name of the table style.
      
       ITableStyle tableStyle = workbook.getTableStyles().get("TableStyleLight11");
       String name = tableStyle.getName();
       
      Returns:
      The name of the table style.
    • getTableStyleElements

      ITableStyleElements getTableStyleElements()
      Returns the ITableStyleElements object.
      
       ITableStyle tableStyle = workbook.getTableStyles().get("TableStyleLight11");
       ITableStyleElements elements = tableStyle.getTableStyleElements();
       
      Returns:
      The ITableStyleElements object; see ITableStyleElements.
    • delete

      void delete()
      Deletes the ITableStyle object.
      
       ITableStyle tableStyle = workbook.getTableStyles().add("TemporaryTableStyle");
       tableStyle.delete();
       
    • duplicate

      ITableStyle duplicate()
      Duplicates the ITableStyle object and returns a reference to the new copy.
      
       ITableStyle sourceStyle = workbook.getTableStyles().get("TableStyleLight11");
       ITableStyle copiedStyle = sourceStyle.duplicate();
       
      Returns:
      The duplicated ITableStyle object.
    • duplicate

      ITableStyle duplicate(String newName)
      Returns a duplicate of this 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);
       
      Parameters:
      newName - The name of the new table style. May be null.
      Returns:
      A copy of the ITableStyle object with the specified name.
    • getShowAsAvailableSlicerStyle

      boolean getShowAsAvailableSlicerStyle()
      Gets whether the specified table style is shown as available in the slicer styles gallery.
      
       ITableStyle slicerStyle = workbook.getTableStyles().add("CustomSlicerStyle");
       slicerStyle.setShowAsAvailableSlicerStyle(true);
       boolean available = slicerStyle.getShowAsAvailableSlicerStyle();
       
      Returns:
      true if the specified table style is shown as available in the slicer styles gallery; otherwise, false.
    • setShowAsAvailableSlicerStyle

      void setShowAsAvailableSlicerStyle(boolean value)
      Sets whether this table style is shown as available in the slicer styles gallery.

      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);
       
      Parameters:
      value - true to show this table style as available in the slicer styles gallery; otherwise, false.
    • getShowAsAvailableTableStyle

      boolean getShowAsAvailableTableStyle()
      Gets whether this table style is shown as available in the table styles gallery.
      
       ITableStyle tableStyle = workbook.getTableStyles().add("CustomTableStyle");
       tableStyle.setShowAsAvailableTableStyle(true);
       boolean available = tableStyle.getShowAsAvailableTableStyle();
       
      Returns:
      true if this table style is shown as available in the table styles gallery; otherwise, false.
    • setShowAsAvailableTableStyle

      void setShowAsAvailableTableStyle(boolean value)
      Sets whether this table style is shown as available in the table styles gallery.

      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);
       
      Parameters:
      value - true to show this style as available in the table styles gallery; false to hide it from the gallery.
    • getShowAsAvailablePivotStyle

      boolean getShowAsAvailablePivotStyle()
      Gets whether this table style is shown as available in the pivot styles gallery.
      
       ITableStyle pivotStyle = workbook.getTableStyles().add("CustomPivotStyle");
       pivotStyle.setShowAsAvailablePivotStyle(true);
       boolean available = pivotStyle.getShowAsAvailablePivotStyle();
       
      Returns:
      true if this table style is shown as available in the pivot styles gallery; otherwise, false.
    • setShowAsAvailablePivotStyle

      void setShowAsAvailablePivotStyle(boolean value)
      Sets whether this table style is shown as available in the pivot styles gallery.

      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);
       
      Parameters:
      value - true to show this style as available in the pivot styles gallery; false to hide it from the gallery.