Thread

Posted on Thu Apr 13 15:45:50 2006 by chrisd
Displaying USD currency in ODS document
I'm trying to display the contents of a cell as type 'currency' (USD), but I'm having trouble getting it to work. Here is my code:
#get a handle for a table that contains one cell my $table = $document->getTable(0, 1, 1); #get a handle for the only cell in the table my $cell = $document->getCell($table, 0,0); $document->cellValueType($cell, 'currency'); $document->cellCurrency($cell, 'USD'); #print the value in the cell $document->updateCell($cell, 95, '$95.00');
I've tried a number of variations for the arguments to updateCell, none of which work. I always either get a plain number or a zero. I have also unsuccessfully tried using a document template from my local copy of OOo (us-EN), as well as explicitly setting my language to us-EN. Any help would be greatly appreciated. Thanks.
Direct Responses: 2170 | Write a response
Posted on Mon Apr 17 21:55:15 2006 by chrisd in response to 2157
Re: Displaying USD currency in ODS document

My problem was that I was trying to create styles programatically, instead of doing it with a pre-made OO document.

I solved the problem by creating a blank workbook (in my en-US version of OO2), adding a currency style, and saving it. Then, I unzipped it into templates/spreadsheet, and explicitly used the template_path parameter in my ooDoc constructor.

Finally, I used the correct style when inserting currency (in addition to setting the value type).

Write a response