[]
        
(Showing Draft Content)

ITableStyleCollection

Interface ITableStyleCollection


public interface ITableStyleCollection
Represents a collection of table styles contained in the workbook.

Provides access to built-in and custom ITableStyle objects in a workbook. Use this interface to retrieve table styles by name or index, check whether a style exists, or add a custom table style through Workbook.getTableStyles().


 ITableStyleCollection tableStyles = workbook.getTableStyles();
 ITableStyle customStyle = tableStyles.add("CustomStyle");
 ITableStyle builtInStyle = tableStyles.get("TableStyleMedium3");
 
  • Method Summary

    Modifier and Type
    Method
    Description
    add(String name)
    Adds a custom table style with the specified name.
    boolean
    Determines whether the collection contains a table style with the specified name.
    get(int index)
    Gets the ITableStyle at the specified index.
    get(String name)
    Gets the ITableStyle with the specified name.
    int
    Gets the number of table styles in the collection.
  • Method Details

    • get

      ITableStyle get(String name)
      Gets the ITableStyle with the specified name.

      Use this method to retrieve a built-in or custom table style from the collection returned by Workbook.getTableStyles().

      
       ITableStyle tableStyle = workbook.getTableStyles().get("TableStyleLight11");
       worksheet.getTables().add(worksheet.getRange("A1:B3"), true).setTableStyle(tableStyle);
       
      Parameters:
      name - The name of the table style to retrieve.
      Returns:
      The ITableStyle object with the specified name.
    • get

      ITableStyle get(int index)
      Gets the ITableStyle at the specified index.

      This method retrieves a table style from the collection returned by Workbook.getTableStyles() using its zero-based position.

      
       ITableStyleCollection tableStyles = workbook.getTableStyles();
       tableStyles.add("CustomTableStyle");
       ITableStyle tableStyle = tableStyles.get(tableStyles.getCount() - 1);
       
      Parameters:
      index - The zero-based index of the table style to retrieve.
      Returns:
      The ITableStyle object at the specified index.
      Throws:
      IndexOutOfBoundsException - if index is less than 0 or greater than or equal to getCount().
    • getCount

      int getCount()
      Gets the number of table styles in the collection.

      This count includes the table styles currently available in the workbook's ITableStyleCollection.

      
       ITableStyleCollection tableStyles = workbook.getTableStyles();
       tableStyles.add("CustomTableStyle");
       int count = tableStyles.getCount();
       
      Returns:
      The number of table styles in the collection.
    • add

      ITableStyle add(String name)
      Adds a custom table style with the specified name.

      Use this method to create an ITableStyle in the workbook table style collection returned by Workbook.getTableStyles().

      
       ITableStyle tableStyle = workbook.getTableStyles().add("CustomTableStyle");
       ITableStyleElement header = tableStyle.getTableStyleElements().get(TableStyleElementType.HeaderRow);
       header.getInterior().setColor(Color.GetBlue());
       
      Parameters:
      name - The name of the table style to add. Must not be null.
      Returns:
      The newly added ITableStyle object.
      Throws:
      IllegalArgumentException - if name is null or a table style with the same name already exists.
    • contains

      boolean contains(String name)
      Determines whether the collection contains a table style with the specified name.

      Use this method to check whether a built-in or custom table style is available in the collection returned by Workbook.getTableStyles().

      
       ITableStyleCollection tableStyles = workbook.getTableStyles();
       tableStyles.add("CustomStyle");
       boolean hasCustomStyle = tableStyles.contains("CustomStyle");
       
      Parameters:
      name - The name of the table style to search for.
      Returns:
      true if contains is enabled; otherwise, false.