Table extends Component { public Column appendColumn() { List<Column> columnList = getColumnList(); int columnCount = columnList.size(); TableTableColumnElement newColumn; OdfElement positonElement = getRowElementByIndex(0); if (positonElement.getParentNode() instanceof TableTableHeaderRowsElement) { positonElement = (OdfElement) positonElement.getParentNode(); } List<Row> rowList = getRowList(); for (int i = 0; i < rowList.size();) { Row row1 = rowList.get(i); row1.insertCellBefore(row1.getCellByIndex(columnCount - 1), null); i = i + row1.getRowsRepeatedNumber(); } if (columnList.size() == 0) { OdfStyle columnStyle = mTableElement.getAutomaticStyles().newStyle(OdfStyleFamily.TableColumn); String columnStylename = columnStyle.getStyleNameAttribute(); columnStyle.setProperty(StyleTableColumnPropertiesElement.ColumnWidth, DEFAULT_TABLE_WIDTH + "in"); columnStyle.setProperty(StyleTableColumnPropertiesElement.RelColumnWidth, DEFAULT_REL_TABLE_WIDTH + "*"); newColumn = (TableTableColumnElement) OdfXMLFactory.newOdfElement((OdfFileDom) mTableElement .getOwnerDocument(), OdfName.newName(OdfDocumentNamespace.TABLE, "table-column")); newColumn.setStyleName(columnStylename); mTableElement.insertBefore(newColumn, positonElement); } else { TableTableColumnElement refColumn = columnList.get(columnList.size() - 1).getOdfElement(); newColumn = (TableTableColumnElement) refColumn.cloneNode(true); String tableNameSpace = OdfDocumentNamespace.TABLE.getUri(); newColumn.removeAttributeNS(tableNameSpace, "number-columns-repeated"); mTableElement.insertBefore(newColumn, positonElement); } return getColumnInstance(newColumn, 0); } private  Table(TableContainer container, TableTableElement table); static Table getInstance(TableTableElement element); static Table newTable(TableContainer tableContainer); static Table newTable(TableContainer tableContainer, int numRows, int numCols); static Table newTable(TableContainer tableContainer, int numRows, int numCols, 
			double marginLeft, double marginRight); static Table newTable(TableContainer tableContainer, int numRows, int numCols, int headerRowNumber,
			int headerColumnNumber); static Table newTable(TableContainer tableContainer, String[] rowLabel, String[] columnLabel, double[][] data); static Table newTable(TableContainer tableContainer, String[] rowLabel, String[] columnLabel, String[][] data); double getWidth(); void setWidth(double width); void applyStyle(TableTemplate template); int getRowCount(); int getColumnCount(); Row appendRow(); List<Row> appendRows(int rowCount); Column appendColumn(); List<Column> appendColumns(int columnCount); TableTableElement getOdfElement(); List<Column> insertColumnsBefore(int index, int columnCount); void removeColumnsByIndex(int startIndex, int deleteColCount); List<Row> insertRowsBefore(int index, int rowCount); List<Column> getColumnList(); Iterator<Column> getColumnIterator(); List<Row> getRowList(); Iterator<Row> getRowIterator(); Column getColumnByIndex(int index); Row getRowByIndex(int index); void removeRowsByIndex(int startIndex, int deleteRowCount); void remove(); int getHeaderRowCount(); int getHeaderColumnCount(); String getTableName(); void setTableName(String tableName); boolean isProtected(); void setProtected(boolean isProtected); boolean isCellStyleInheritance(); void setCellStyleInheritance(boolean isEnabled); boolean isUseRepeat(); void setUseRepeat(boolean isSingle); CellRange getCellRangeByPosition(int startCol, int startRow, int endCol, int endRow); CellRange getCellRangeByPosition(String startAddress, String endAddress); CellRange getCellRangeByName(String name); Cell getCellByPosition(int colIndex, int rowIndex); Cell getCellByPosition(String address); void setVerticalMargin(double spaceTop, double spaceBottom); DefaultStyleHandler getStyleHandler();  }
@Test public void testAppendColumn() { mOdtDoc = loadODTDocument(mOdtTestFileName + ".odt"); List<Table> tableList = mOdtDoc.getTableList(); for (int i = 0; i < tableList.size(); i++) { Table table = tableList.get(i); int clmnum = table.getColumnCount(); table.appendColumn(); Assert.assertEquals(clmnum + 1, table.getColumnCount()); Column column = table.getColumnByIndex(clmnum); Column columnOld = table.getColumnByIndex(clmnum - 1); Assert.assertEquals(column.getCellCount(), columnOld.getCellCount()); } saveodt(mOdtTestFileName + "Output.odt"); }