Thread

Posted on Wed Jul 4 00:22:00 2007 by petert
problem with leading characters
I'm trying to get data from multiple spreadsheets and combine them into one but whenever I read a number (such as 01/08/06) it get's turned into '2006-01-08 or (34 into '34). How do I keep this from happening? The ooCalc spreadsheets have default style/formatting settings. Here's a snippet of the code:
#get the date from little spread sheet and copy it into the big one while($date = $little_doc ->cellValue($little_sheet, $little_column . "1")){ $big_doc ->cellValue($big_sheet, $big_column . "1", $date); print "just wrote data: $date to big_spread\n"; $little_column++; $big_column++; }
Thanks in advance for any help, Pete.
Direct Responses: 5631 | Write a response
Posted on Wed Jul 4 14:44:13 2007 by jmgdoc in response to 5619
Re: problem with leading characters
The cellValue() method, when used with a numeric cell, returns the value in a standard, computable format. The display format is ignored. So, if the type of the cell is "date", the value is returned as an ISO-8601 compliant string. It's a design choice of the API, allowing the applications to get consistently formatted numeric values that doesn't depend of the external layout or the cells.
However, there is a simple way to get the display content of a cell (as it was recorded by OpenOffice.org). To do so, one cas select the "paragraph" element of the cell, then get the content of this paragraph. Example:
my $p = $doc->getCellParagraph($sheet, $col, $row); my $text = $doc->getText($p);

Beware: the applications should avoid updating a cell paragraph by setText(), knowing that they could produce inconsistencies between the cell display value and the cell computable value.
Direct Responses: 5651 | Write a response
Posted on Fri Jul 6 20:28:23 2007 by petert in response to 5631
Re: problem with leading characters
Thanks for taking the time to explain that and help a noob. Everything works great now.
Write a response