Document Solutions for Excel, Java Edition | Document Solutions
Features / Table / Create and Delete Tables
In This Topic
    Create and Delete Tables
    In This Topic

    In DsExcel Java, you can create and delete tables in spreadsheets using the add method of the ITables interface and the delete method of the ITable interface, or simply transform a cell range into a table by specifying the existing data lying in a worksheet.

    In order to create and delete tables in a worksheet, refer to the following example code.

    Java
    Copy Code
    //Create workbook and access the worksheet
    Workbook workbook = new Workbook();
    IWorksheet worksheet = workbook.getWorksheets().get(0);
            
    // Add first table
    ITable table1 = worksheet.getTables().add(worksheet.getRange("A1:E5"), true);
            
    // Add second table
    ITable table2 = worksheet.getTables().add(worksheet.getRange("N1:R5"), true);
    
    // Delete first table
    worksheet.getTables().get(0).delete();
    Note: DsExcel also supports defined names, which can be used to name the table. For more information, see Defined Names.