OpenOffice documents are in a compressed XML format and before you can add rows and columns you need to account for this compression. From the
OpenOffice::OODoc docs:
Caution: The direct cell addressing works only when the table XML storage is "normalized", i.e. when every table object (row, column or cell) is mapped to an exclusive XML element... with OpenOffice.org Calc spreadsheets, several contiguous objects are mapped to a single XML element as long as they have the same content, the same type and the same presentation.
And also:
before addressing cells in a spreadsheet document, a program must "declare" the size of the used area in each target sheet
So you will need to call expandTable() to the correct size, which also "normalizes" the sheet, and then use getCell() / updateCell(), or the shortcut cellValue(), to insert the new cell. But there is a gotcha with expandTable() - from the
OpenOffice::OODoc::Text docs:
expandTable(table, height, width)
The vertical expansion is implemented by repetitive replication of the
last row, while the horizontal expansion is implemented by repetitive
replication of the last cell of the last row. So the new cells in the
right side are copies of the old bottom-right cell, while the new rows
are copies of the old last row.
So you will need to deal with any values in the last row and column. It may be easier to copy the old values and create a new document, or if you need to retain the formatting of the old document you could empty the values, resize the sheet, and then re-insert them.