Thread

Posted on Sun Oct 23 10:29:45 2005 by cilynx
ODS Adjacent Cell Problems
I'm working on pulling a lot of info off of ODS sheets to be reformatted and redisplayed on a web site depending on user preferences. I've run into a stumbling block that I can't find any way around:

When adjacent cells of a sheet have the same content, none but the first are noticed by the parser. The rest of the cells in the row get shifted into the "void" created by the missing cells. This throws off the columns of the rest of the table. I've attempted getTableText(), looping through getTableRow(), and manually walking the table with getCellValue() and a for loop. Every method I can come up with gives the same result: If that value of two or more adjacent cells is the same, the parser skips all but the first.

A little code and output in case I'm not making any sense:

rcw@pyth:~/Desktop/Sybase$ cat test.pl #!/usr/bin/perl -w # Don't step on our toes use strict; # We need OpenDocument support for the spreadsheet use OpenOffice::OODoc; my $SHEET = 0; my $INFILE = shift(@ARGV) or die "Usage: $0 <input file>"; my $DOC = ooDocument(file => $INFILE); my $Table = $DOC->getTableText($SHEET); print "$Table\n"; rcw@pyth:~/Desktop/Sybase$ cat Test.csv 1;2;3;4;5 "y";"y";"n";"n";"n" "n";"n";"n";"n";"y" 1;1;1;1;1 "car";"truck";"truck";"car";"car" rcw@pyth:~/Desktop/Sybase$ ./test.pl Test.ods 1;2;3;4;5 y;n n;y 1 car;truck;car rcw@pyth:~/Desktop/Sybase$

I've got OpenOffice::OODoc 2.011 installed. I couldn't find 2.012 available for download yet.

The CSV was made off of the ODS by OOo right before running the test. Please tell me that this is some mistake that I made and that there is an easy fix. If life isn't that easy, consider this a bug report...thanks...
Direct Responses: 1218 | Write a response
Posted on Sun Oct 23 13:21:33 2005 by jmgdoc in response to 1217
Re: ODS Adjacent Cell Problems

When adjacent cells have the same content, OOo stores the content once, with a 'repeated' attribute.
Subsequent rows with the same content are stored in the same way.
So, by default, there is no one-to-one mapping between stored and displayed cells.
Before addressing row and cells in a spreadsheet, you must explictly declare an area, beginning in the top left cell ("A1"), with given height and width. This area (and only this area) is preprocessed in order to implement a normalized mapping, allowing subsequent direct cell addressing by logical coordinates.
You can do that with the getTable() method, with the two optional size arguments. Example:
my $sheet = $doc->getTable("Sheet1", 25, 18);

The instruction above normalizes the cell addressing scheme for a 25x16 area in a given sheet.
See getTable() and normalizeSheet() in the OpenOffice::OODoc::Text man page.

(There is no difference between 2.011 and 2.012 about table cell addressing.)
Write a response