}
// add a new row at the end of the table
textTable.addRow(1);
ITextTableRow row = textTable.getRow(textTable.getRowCount()-1);
ITextTableColumn[] columns = textTable.getColumns();
// we want the sum of each column in the last row
for(int i=0;i<columns.length;i++) {
ITextTableCell[][] cells = columns[i].getCellRange().getCells();
//we need all but the last cell in the column (the last will be the formula)
StringBuffer cellNames = new StringBuffer();
for(int x=0;x<cells.length-1;x++) {
cellNames.append("<"+cells[x][0].getName().getName()+">");
if(x<cells.length-2) {
cellNames.append("+");
}
}
ITextTableCell formulaCell= row.getCells()[i];
formulaCell.getFormulaService().setFormula(cellNames.toString());
}
}
catch (TextException exception) {
exception.printStackTrace();