# Modify Tables

DsExcel allows you to modify table range, table areas, and totals row of table column.

## Content

While working with tables in DsExcel Java, you can configure it as per your spreadsheet requirements by modifying the table using the methods of the [ITable](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/ITable.html) interface.

* [Modify table range](/document-solutions/java-excel-api/docs/online/Features/UseTable/ModifyTables#modify-table-range)
* [Modify table areas](/document-solutions/java-excel-api/docs/online/Features/UseTable/ModifyTables#modify-table-areas)
* [Modify totals row of table column](/document-solutions/java-excel-api/docs/online/Features/UseTable/ModifyTables#modify-totals-row-of-table-column)

## Modify table range

You can modify the table range of your worksheet using the [resize](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/ITable.html#resize) method of the [ITable](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/ITable.html) interface.
In order to modify table range, refer to the following example code.

```Java
// Modify table range
table.resize(worksheet.getRange("B1:E4"));
```

## Modify table areas

You can modify the value of specific table areas by accessing its header range, data range and total range using the [getHeaderRange](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/ITable.html#getHeaderRange) method, [getDataRange](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/ITable.html#getDataRange) method and [getTotalsRange](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/ITable.html#getTotalsRange) method of the [ITable](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/ITable.html) interface.
In order to modify table areas in your worksheet, refer to the following example code.

```Java
ITable table = worksheet.getTables().add(worksheet.getRange("A1:E5"), true);
table.setShowTotals(true);
        
// Populate table values
        
worksheet.getRange("A2").setValue(3);
worksheet.getRange("A3").setValue(4);
worksheet.getRange("A4").setValue(2);
worksheet.getRange("A5").setValue(1);
worksheet.getRange("B2").setValue(32);
worksheet.getRange("B3").setValue(41);
worksheet.getRange("B4").setValue(12);
worksheet.getRange("B5").setValue(16);
worksheet.getRange("C2").setValue(3);
worksheet.getRange("C3").setValue(4);
worksheet.getRange("C4").setValue(15);
worksheet.getRange("C5").setValue(18);
        
// Table second column name set to "Age".
worksheet.getTables().get(0).getHeaderRange().get(0, 1).setValue("Age");

// "Age" Column's second row's value set to 23.
worksheet.getTables().get(0).getDataRange().get(1, 1).setValue(23);

// "Age" column's total row function set to average.
worksheet.getTables().get(0).getTotalsRange().get(0, 1).setFormula("=SUBTOTAL(101,[Age])");
```

## Modify totals row of table column

When you need to make changes to the total row's calculation function of a specific table column, you can use the [setTotalsCalculation](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/ITableColumn.html#setTotalsCalculation) method of the [ITableColumn](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/ITableColumn.html) interface.
Refer to the following example code to modify column total row's calculation function.

```Java
Workbook workbook = new Workbook();
IWorksheet worksheet = workbook.getWorksheets().get(0);
worksheet.getTables().add(worksheet.getRange("A1:E5"), true);
 
// Populate table values
worksheet.getRange("A2").setValue(3);
worksheet.getRange("A3").setValue(4);
worksheet.getRange("A4").setValue(2);
worksheet.getRange("A5").setValue(1);
worksheet.getRange("B2").setValue(32);
worksheet.getRange("B3").setValue(41);
worksheet.getRange("B4").setValue(12);
worksheet.getRange("B5").setValue(16);
worksheet.getRange("C2").setValue(3);
worksheet.getRange("C3").setValue(4);
worksheet.getRange("C4").setValue(15);
worksheet.getRange("C5").setValue(18);
        
// First table column's total row calculation fuction will be "=SUBTOTAL(101,[Column1])"
worksheet.getTables().get(0).getColumns().get(0).setTotalsCalculation(TotalsCalculation.Average);
worksheet.getTables().get(0).setShowTotals(true);
```