Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Weird behaviour with libreoffice spreadsheet and OpenOffice::OODoc

by tangent (Vicar)
on Mar 24, 2016 at 16:33 UTC ( #1158730=note: print w/replies, xml ) Need Help??


in reply to Weird behaviour with libreoffice spreadsheet and OpenOffice::OODoc

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.
  • Comment on Re: Weird behaviour with libreoffice spreadsheet and OpenOffice::OODoc

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1158730]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2022-05-22 12:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (80 votes). Check out past polls.

    Notices?