Thread

Posted on Fri Jun 15 21:11:22 2007 by harryc
OODOC does not seem to work what do i do wrong
Hi i have installed openoffice 2.1 dutch on a XP and i want to make some spreadsheets with OODOC
For testing i made a file with in sheet 1 wich is in dutch Blad1 in D1 i put a 1
then i run following script

sub makencalc { use OpenOffice::OODoc; my $doc = ooDocument(file => "$path_to_files\\verschillenstaatsjabloon.ods"); my $testt = $doc->cellValue("Sheet1","D1"); print "test: $testt\n"; $testt = $doc->cellValue("Blad1","D1"); print "test: $testt\n"; $doc->cellValue("Sheet1", "A5", 'test text english '); $doc->cellValue("Blad1", "A6", "test text dutch"); $doc->save("$path_to_files\\verschillenstaat.ods"); }

Nothing seems to happen $testt is empty
The only thing that happens is verschillenstaatsjabloon.ods is copied
to verschillenstaat.ods
what do i do wrong ?
thks
Harry
Direct Responses: 5450 | Write a response
Posted on Sat Jun 16 13:29:34 2007 by jmgdoc in response to 5446
Re: OODOC does not seem to work what do i do wrong

Beware, a spreadsheet tab should be normalized before any cell operation. Knowing that the ODS format allows storage denormalization (i.e. more than one table cell can be stored in a single XML element), the result of a direct cell adressing operation (like "Sheet1", "D1") is unpredictable as long as the target area has not been pre-processed through getTable or normalizeSheet.

Note that this pre-processing is required once, and not before each cell access.

The following code should work better (the given size for getTable is an example; one should provide the size of a 0,0-based area which covers all the cells that will be addressed.
See getTable and normalizeSheet in the OpenOffice::OODoc::Text manual for details about the spreadsheet addressing logic.
my $doc = ooDocument(file => "$path_to_files\\verschillenstaatsjabloon.ods"); my $sheet = $doc->getTable("Sheet1", 10, 10); my $testt = $doc->cellValue($sheet,"D1"); #...
Write a response