Posted on 2005-10-23 07:29:45-07 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
Perl Weekly newsletter
A free weekly newsletter for people who are busy to read all the blogs. click here to check it out.