Document Solutions for Excel, Java Edition | Document Solutions
Features / Table / Table Style
In This Topic
    Table Style
    In This Topic

    DsExcel Java enables users to create custom table style elements and apply them to a worksheet using the ITableStyle interface. Also, users can format a table using any of the predefined table styles as per their preferences.

    Generally, each workbook stores both built-in and custom table styles. If you want to insert a custom table style, you use the add method of the ITables interface, which returns the IStyle object representing the corresponding table style instance.

    In order to apply table style in a worksheet, refer to the following example code.

    Java
    Copy Code
    // Use table style name get one build in table style.
    ITableStyle tableStyle = workbook.getTableStyles().get("TableStyleLight11");
    worksheet.getTables().add(worksheet.getRange(0, 0, 2, 2), true);
    
    // Set built-in table style to table.
    worksheet.getTables().get(0).setTableStyle(tableStyle);