[]
An ITable defines a structured data region that can include a header row, data rows, totals, filtering, sorting, and table-specific formatting. Calling ITables.add(IRange,boolean) to add a table to a worksheet returns an ITable object.
worksheet.getRange("A1:B3").setValue(new Object[][] {
{"Name", "Value"},
{"Test", 100},
{"Hello", 200}
});
ITable table = worksheet.getTables().add(worksheet.getRange("A1:B3"), true);
table.setDisplayName("Table1");
voidvoiddelete()ITable object and clears the cell data from the worksheet.voidIAutoFilter for this table.booleanITable.IRange that represents the data area of the table.ITable.booleanIRange object that represents the header row of the table.getName()getRange()IRange object that represents the range to which the specified table object applies.getRows()ITable.booleanbooleanbooleanITable displays the header row that contains column names.booleanITable.booleanbooleanbooleanITable.booleangetSort()ITable.voidITable to a new range without inserting or moving cells.voidsetAutoGenerateColumns(boolean value) voidsetBindingPath(String value) voidsetComment(String value) voidsetDisplayName(String value) ITable.voidsetExpandBoundRows(boolean value) voidvoidsetShowAutoFilter(boolean value) voidsetShowAutoFilterDropDown(boolean value) voidsetShowHeaders(boolean value) ITable displays the header row that contains column names.voidsetShowTableStyleColumnStripes(boolean value) ITable.voidsetShowTableStyleFirstColumn(boolean value) ITable.voidsetShowTableStyleLastColumn(boolean value) ITable.voidsetShowTableStyleRowStripes(boolean value) ITable.voidsetShowTotals(boolean value) voidsetTableStyle(ITableStyle value) toJson()Use this method to retrieve the table name that identifies the table in the worksheet.
worksheet.getRange("A1:B3").setValue(new Object[][] {
{"Product", "Amount"},
{"Apple", 100},
{"Orange", 200}
});
ITable table = worksheet.getTables().add(worksheet.getRange("A1:B3"), true);
table.setName("SalesTable");
String name = table.getName();
Use this method to set the table name that identifies the table in the worksheet.
worksheet.getRange("A1:B3").setValue(new Object[][] {
{"Product", "Amount"},
{"Apple", 100},
{"Orange", 200}
});
ITable table = worksheet.getTables().add(worksheet.getRange("A1:B3"), true);
table.setName("SalesTable");
ITable namedTable = worksheet.getTables().get("SalesTable");
String namedTableAddress = namedTable.getRange().getAddress();
value - The name of the table.ITable. The display name is the user-facing name of the table.
worksheet.getRange("A1:B3").setValue(new Object[][] {
{"Product", "Amount"},
{"Apple", 100},
{"Orange", 200}
});
ITable table = worksheet.getTables().add(worksheet.getRange("A1:B3"), true);
table.setDisplayName("SalesTable");
String displayName = table.getDisplayName();
ITable.ITable. The display name is the user-facing name of the table.
worksheet.getRange("A1:B3").setValue(new Object[][] {
{"Product", "Amount"},
{"Apple", 100},
{"Orange", 200}
});
ITable table = worksheet.getTables().add(worksheet.getRange("A1:B3"), true);
table.setDisplayName("SalesTable");
value - The display name for the specified ITable.This method returns the text previously assigned through setComment(String) for the current table.
worksheet.getRange("A1:B3").setValue(new Object[][] {
{"Name", "Value"},
{"Test", 100},
{"Total", 200}
});
ITable table = worksheet.getTables().add(worksheet.getRange("A1:B3"), true);
table.setComment("Monthly summary table");
String comment = table.getComment();
Use this method to assign the comment text for the current table.
worksheet.getRange("A1:B3").setValue(new Object[][] {
{"Name", "Value"},
{"Test", 100},
{"Total", 200}
});
ITable table = worksheet.getTables().add(worksheet.getRange("A1:B3"), true);
table.setComment("Monthly summary table");
value - The comment associated with the table object.ITable. The returned ISort object provides access to the sort fields and sort order applied to the table data. After configuring the sort fields, call ISort.apply() to sort the table.
worksheet.getRange("A1:B4").setValue(new Object[][] {
{"Name", "Score"},
{"Tom", 80},
{"Nancy", 95},
{"Jack", 88}
});
ITable table = worksheet.getTables().add(worksheet.getRange("A1:B4"), true);
ISort sort = table.getSort();
sort.getSortFields().add(new ValueSortField(worksheet.getRange("B2:B4"), SortOrder.Descending));
sort.apply();
ITable.IAutoFilter for this table.The returned auto filter represents the filtering settings that apply to the table range.
worksheet.getRange("A1:C4").setValue(new Object[][] {
{"Name", "Value", "Category"},
{"A", 100, "X"},
{"B", 200, "Y"},
{"C", 100, "X"}
});
ITable table = worksheet.getTables().add(worksheet.getRange("A1:C4"), true);
table.getRange().autoFilter(2, "X");
IAutoFilter autoFilter = table.getAutoFilter();
Object criteria1 = autoFilter.getFilters().get(2).getCriteria1();
IAutoFilter for this table.IRange object that represents the range to which the specified table object applies.
worksheet.getRange("A1:B3").setValue(new Object[][] {{"Name", "Value"}, {"A", 100}, {"B", 200}});
ITable table = worksheet.getTables().add(worksheet.getRange("A1:B3"), true);
IRange tableRange = table.getRange();
IRange object that represents the range to which the specified table object applies.IRange that represents the data area of the table.The returned range contains the table rows between the header row and the insert row. It does not include the header row.
worksheet.getRange("A1:B3").setValue(new Object[][] {
{"Name", "Value"},
{"Apple", 100},
{"Pear", 200}
});
ITable table = worksheet.getTables().add(worksheet.getRange("A1:B3"), true);
IRange dataRange = table.getDataRange();
IRange that represents the data area of the table.IRange object that represents the header row of the table.Use this method to access the cells that contain the table column headers.
worksheet.getRange("A1:B3").setValue(new Object[][] {
{"Product", "Amount"},
{"Apple", 100},
{"Pear", 200}
});
ITable table = worksheet.getTables().add(worksheet.getRange("A1:B3"), true);
IRange headerRange = table.getHeaderRange();
headerRange.get(0, 1).setValue("Total");
IRange object that represents the header row of the table.Returns the IRange that represents the totals row of this ITable when the totals row is visible.
worksheet.getRange("A1:B3").setValue(new Object[][] {
{"Product", "Amount"},
{"Apple", 100},
{"Orange", 200}
});
ITable table = worksheet.getTables().add(worksheet.getRange("A1:B3"), true);
table.setShowTotals(true);
IRange totalsRange = table.getTotalsRange();
IRange that represents the totals row of the table.This method returns true only when the table headers are displayed and AutoFilter is enabled for the table.
worksheet.getRange("A1:B3").setValue(new Object[][] {
{"Name", "Value"},
{"Test", 100},
{"Hello", 200}
});
ITable table = worksheet.getTables().add(worksheet.getRange("A1:B3"), true);
table.setShowAutoFilter(true);
boolean showAutoFilter = table.getShowAutoFilter();
This method Sets true only when the table headers are displayed and AutoFilter is enabled for the table.
worksheet.getRange("A1:B3").setValue(new Object[][] {
{"Name", "Value"},
{"Test", 100},
{"Hello", 200}
});
ITable table = worksheet.getTables().add(worksheet.getRange("A1:B3"), true);
table.setShowAutoFilter(true);
value - Whether the AutoFilter is displayed.This property indicates whether the drop-down buttons are shown in the table header row.
worksheet.getRange("A1:B3").setValue(new Object[][] {
{"Name", "Value"},
{"Test", 100},
{"Hello", 200}
});
ITable table = worksheet.getTables().add(worksheet.getRange("A1:B3"), true);
boolean showAutoFilterDropDown = table.getShowAutoFilterDropDown();
This property indicates whether the drop-down buttons are shown in the table header row.
worksheet.getRange("A1:B3").setValue(new Object[][] {
{"Name", "Value"},
{"Test", 100},
{"Hello", 200}
});
ITable table = worksheet.getTables().add(worksheet.getRange("A1:B3"), true);
table.setShowAutoFilterDropDown(true);
value - Whether the table filter button is visible.ITable displays the header row that contains column names. Use this property to check whether the table displays a header row that contains column names.
worksheet.getRange("A1:B3").setValue(new Object[][] {
{"Name", "Value"},
{"Apple", 100},
{"Orange", 200}
});
ITable table = worksheet.getTables().add(worksheet.getRange("A1:B3"), true);
boolean showHeaders = table.getShowHeaders();
ITable displays the header row that contains column names; otherwise, false.ITable displays the header row that contains column names. Use this property to set whether the table displays a header row that contains column names.
worksheet.getRange("A1:B3").setValue(new Object[][] {
{"Name", "Value"},
{"Apple", 100},
{"Orange", 200}
});
ITable table = worksheet.getTables().add(worksheet.getRange("A1:B3"), true);
table.setShowHeaders(true);
value - Whether this ITable displays the header row that contains column names.ITable. When this property is true, the applied table style uses alternating formatting for table columns.
worksheet.getRange("A1:C3").setValue(new Object[][] {
{"Name", "Q1", "Q2"},
{"Tea", 100, 120},
{"Coffee", 90, 110}
});
ITable table = worksheet.getTables().add(worksheet.getRange("A1:C3"), true);
table.setShowTableStyleColumnStripes(true);
boolean showColumnStripes = table.getShowTableStyleColumnStripes();
ITable; otherwise, false.ITable. When this property is true, the applied table style uses alternating formatting for table columns.
worksheet.getRange("A1:C3").setValue(new Object[][] {
{"Name", "Q1", "Q2"},
{"Tea", 100, 120},
{"Coffee", 90, 110}
});
ITable table = worksheet.getTables().add(worksheet.getRange("A1:C3"), true);
table.setShowTableStyleColumnStripes(true);
value - Whether the column stripe table style is applied to this ITable.This property indicates whether the table style is applied to the first column of the current ITable.
worksheet.getRange("A1:B3").setValue(new Object[][] {
{"Name", "Amount"},
{"Apple", 100},
{"Orange", 200}
});
ITable table = worksheet.getTables().add(worksheet.getRange("A1:B3"), true);
table.setShowTableStyleFirstColumn(true);
boolean showFirstColumn = table.getShowTableStyleFirstColumn();
ITable. This property indicates whether the first-column table style element is applied to the first column of the current ITable.
worksheet.getRange("A1:B3").setValue(new Object[][] {
{"Name", "Amount"},
{"Apple", 100},
{"Orange", 200}
});
ITable table = worksheet.getTables().add(worksheet.getRange("A1:B3"), true);
table.setShowTableStyleFirstColumn(true);
value - Whether the first-column table style element is applied to the first column of the current ITable.This property indicates whether the table style is applied to the last column of the current ITable.
worksheet.getRange("A1:B3").setValue(new Object[][] {
{"Name", "Amount"},
{"Apple", 100},
{"Pear", 200}
});
ITable table = worksheet.getTables().add(worksheet.getRange("A1:B3"), true);
table.setShowTableStyleLastColumn(true);
boolean showTableStyleLastColumn = table.getShowTableStyleLastColumn();
ITable. This property indicates whether the last-column table style element is applied to the last column of the current ITable.
worksheet.getRange("A1:B3").setValue(new Object[][] {
{"Name", "Amount"},
{"Apple", 100},
{"Pear", 200}
});
ITable table = worksheet.getTables().add(worksheet.getRange("A1:B3"), true);
table.setShowTableStyleLastColumn(true);
value - Whether the last column style is displayed for this ITable.ITable. When this property is true, the applied table style uses alternating row formatting.
worksheet.getRange("A1:B3").setValue(new Object[][] {
{"Name", "Value"},
{"Tea", 10},
{"Coffee", 12}
});
ITable table = worksheet.getTables().add(worksheet.getRange("A1:B3"), true);
boolean showRowStripes = table.getShowTableStyleRowStripes();
ITable; otherwise, false.ITable. When this property is true, the applied table style uses alternating row formatting.
worksheet.getRange("A1:B3").setValue(new Object[][] {
{"Name", "Value"},
{"Tea", 10},
{"Coffee", 12}
});
ITable table = worksheet.getTables().add(worksheet.getRange("A1:B3"), true);
table.setShowTableStyleRowStripes(true);
value - Whether banded rows are displayed for this ITable.Use this method to determine whether the table currently displays a totals row.
worksheet.getRange("A1:B3").setValue(new Object[][] {
{"Product", "Amount"},
{"Apple", 100},
{"Orange", 200}
});
ITable table = worksheet.getTables().add(worksheet.getRange("A1:B3"), true);
table.setShowTotals(true);
boolean showTotals = table.getShowTotals();
Use this method to set whether the table currently displays a totals row.
worksheet.getRange("A1:B3").setValue(new Object[][] {
{"Product", "Amount"},
{"Apple", 100},
{"Orange", 200}
});
ITable table = worksheet.getTables().add(worksheet.getRange("A1:B3"), true);
table.setShowTotals(true);
value - Whether the totals row is visible.ITable. The returned ITableColumns collection contains all columns that belong to the table, including their names and data ranges.
worksheet.getRange("A1:B3").setValue(new Object[][] {
{"Name", "Sales"},
{"Apple", 100},
{"Orange", 200}
});
ITable table = worksheet.getTables().add(worksheet.getRange("A1:B3"), true);
ITableColumns columns = table.getColumns();
ITableColumn salesColumn = columns.get(1);
ITableColumns collection of columns in this ITable.ITable. The returned ITableRows object contains the ITableRow objects that belong to the table data area.
worksheet.getRange("A1:B3").setValue(new Object[][] {
{"Name", "Value"},
{"Apple", 100},
{"Pear", 200}
});
ITable table = worksheet.getTables().add(worksheet.getRange("A1:B3"), true);
ITableRows rows = table.getRows();
ITableRow firstRow = rows.get(0);
ITableRows collection of data rows in this ITable.The returned ITableStyle represents the style currently applied to the table, including built-in and custom table styles.
worksheet.getRange("A1:B3").setValue(new Object[][] {
{"Name", "Value"},
{"Apple", 100},
{"Orange", 200}
});
ITable table = worksheet.getTables().add(worksheet.getRange("A1:B3"), true);
table.setTableStyle(workbook.getTableStyles().get("TableStyleLight11"));
ITableStyle tableStyle = table.getTableStyle();
Use this method to apply a built-in or custom table style to the table.
worksheet.getRange("A1:B3").setValue(new Object[][] {
{"Name", "Value"},
{"Apple", 100},
{"Orange", 200}
});
ITable table = worksheet.getTables().add(worksheet.getRange("A1:B3"), true);
table.setTableStyle(workbook.getTableStyles().get("TableStyleLight11"));
value - The table style applied to the table.ITable to a new range without inserting or moving cells.The new range must remain on the same header row as the current table and must overlap the current table range. This method does not rearrange worksheet cells; it only updates the table boundary.
worksheet.getRange("A1:C4").setValue(new Object[][] {
{"Name", "Region", "Sales"},
{"Alice", "East", 100},
{"Bob", "West", 120},
{"Carol", "North", 140}
});
ITable table = worksheet.getTables().add(worksheet.getRange("A1:C4"), true);
worksheet.getRange("D1:D4").setValue(new Object[][] {
{"Status"},
{"Open"},
{"Closed"},
{"Open"}
});
table.resize(worksheet.getRange("A1:D4"));
range - The new table range. Must be a single, non-empty IRange that overlaps the current table range.IllegalArgumentException - if range is null, empty, contains multiple selections, does not overlap the current table range, or does not start on the same row as the current table.UnsupportedOperationException - if the table is bound to a data manager.ITable object and clears the cell data from the worksheet.Use this method to remove both the table definition and the cells covered by the table. To keep the data and remove only the table object, use convertToRange() instead.
worksheet.getRange("A1:B3").setValue(new Object[][] {
{"Name", "Value"},
{"Test", 100},
{"Sample", 200}
});
ITable table = worksheet.getTables().add(worksheet.getRange("A1:B3"), true);
table.delete();
The binding path identifies the data path used when the table is bound to a data source.
worksheet.setDataSource(new JsonDataSource(
"{\"sales\":[{\"name\":\"Alice\",\"amount\":100},{\"name\":\"Bob\",\"amount\":200}]}"));
ITable table = worksheet.getTables().add(worksheet.getRange("A1:B3"), true);
table.getColumns().get(0).setDataField("name");
table.getColumns().get(1).setDataField("amount");
table.setBindingPath("sales");
String bindingPath = table.getBindingPath();
The binding path identifies the data path used when the table is bound to a data source.
worksheet.setDataSource(new JsonDataSource(
"{\"sales\":[{\"name\":\"Alice\",\"amount\":100},{\"name\":\"Bob\",\"amount\":200}]}"));
ITable table = worksheet.getTables().add(worksheet.getRange("A1:B3"), true);
table.getColumns().get(0).setDataField("name");
table.getColumns().get(1).setDataField("amount");
table.setBindingPath("sales");
Object firstName = worksheet.getRange("A2").getValue();
value - The binding path of the current table.When this property is true, the table can create columns from the fields in the bound data source during data binding.
worksheet.setDataSource(new JsonDataSource("{\"ds\":[{\"name\":\"jack\",\"age\":12}]}"));
ITable table = worksheet.getTables().add(worksheet.getRange("A1:C2"), true);
table.setAutoGenerateColumns(true);
table.setBindingPath("ds");
boolean autoGenerateColumns = table.getAutoGenerateColumns();
When this property is true, the table can create columns from the fields in the bound data source during data binding.
worksheet.setDataSource(new JsonDataSource("{\"ds\":[{\"name\":\"jack\",\"age\":12}]}"));
ITable table = worksheet.getTables().add(worksheet.getRange("A1:C2"), true);
table.setAutoGenerateColumns(true);
table.setBindingPath("ds");
value - Whether the table generates columns automatically when it is bound to a data source.
worksheet.getRange("A1:B3").setValue(new Object[][] {{"Name", "Value"}, {"A", 100}, {"B", 200}});
ITable table = worksheet.getTables().add(worksheet.getRange("A1:B3"), true);
String json = table.toJson();
table.fromJson(json);
json - The JSON string used to generate the table.
worksheet.getRange("A1:B3").setValue(new Object[][] {{"Name", "Value"}, {"A", 100}, {"B", 200}});
ITable table = worksheet.getTables().add(worksheet.getRange("A1:B3"), true);
String json = table.toJson();
This property indicates whether the table is allowed to expand or shrink by whole rows when its bound data changes.
worksheet.getRange("A1:B3").setValue(new Object[][] {
{"Name", "Value"},
{"Item A", 100},
{"Item B", 200}
});
ITable table = worksheet.getTables().add(worksheet.getRange("A1:B3"), true);
table.setExpandBoundRows(true);
boolean expandBoundRows = table.getExpandBoundRows();
This property indicates whether the table is allowed to expand or shrink by whole rows when its bound data changes.
worksheet.getRange("A1:B3").setValue(new Object[][] {
{"Name", "Value"},
{"Item A", 100},
{"Item B", 200}
});
ITable table = worksheet.getTables().add(worksheet.getRange("A1:B3"), true);
table.setExpandBoundRows(true);
value - Whether the table can add or delete entire worksheet rows during data binding.After calling this method, the cells remain on the worksheet as normal range data instead of being managed as an ITable.
worksheet.getRange("A1:B3").setValue(new Object[][] {
{"Name", "Value"},
{"Test", 100},
{"Hello", 200}
});
ITable table = worksheet.getTables().add(worksheet.getRange("A1:B3"), true);
table.convertToRange();