Thread

Posted on Thu Jun 21 11:16:29 2007 by harryc
formula question in table
Hi
thanks for the reply on my first message it helped me a lot
i am trying to make a table with oodoc
i have suceeded for some part
i created a template document with a emty tabel with 3 rows and 8 columns,
a header with text in it and two empty rows.
i open the template and insert data and rows .
and save the document as a new odt file.
That works fine.
Now i want to have in the last collumn the a calculation column4 - column5.
If i put in my template in the last collumn
=E<2>-F<2>
then with insert rows it stays
=E2-F2 and does not change in =E3-F3
i tried to code it with:
$rijenteller =1 ; foreach $basisstnr (sort keys %verschiltabel) { my $cell = $document->getCell("$table",$rijenteller, 0); $document->cellValue($cell,$basisstnr ); $document->cellValue("$table",$rijenteller,7,"=<E$rijenteller>-<F$rijenteller>"); $document->insertRow("$table",$rijenteller,position => 'after'); $rijenteller += 1;:<br> }
but that does not work either
It only puts text in the column not a formula
How should I proceed ?
thks
Harry
Direct Responses: 5499 | Write a response
Posted on Thu Jun 21 12:43:57 2007 by jmgdoc in response to 5497
Re: formula question in table
The cellValue() method can't put a formula; cellFormula() is available for the job.
Beware, the calculation formulae are not covered by the OpenDocument specification, so the syntax depends on the software which will be used to display the document. As an example, the following code works if the target table belongs to a text document to be displayed with OpenOffice.org Writer:
$doc->cellFormula($cell, "<F2>-<F1>");

But if the table is an OpenOffice.org Calc spreadsheet, the correct syntax is:
$doc->cellFormula($cell, "oooc:=[.F2]-[.F1]");
Direct Responses: 5505 | Write a response
Posted on Thu Jun 21 19:04:46 2007 by harryc in response to 5499
Re: formula question in table
thks
it works
Write a response