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.

In reply to Re: Weird behaviour with libreoffice spreadsheet and OpenOffice::OODoc by tangent
in thread Weird behaviour with libreoffice spreadsheet and OpenOffice::OODoc by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.