Accountancy Style

Topics: Developer Forum, User Forum
Jul 20, 2009 at 11:05 AM

 

Hi,

I'm trying to format a cell with the "Accountancy" style:
$format = '_-£* #,##0.00_-;-£* #,##0.00_-;_-£* "-"??_-;_-@_-'; $objPHPExcel->getActiveSheet()->getStyle('F'.$current)->getNumberFormat()->setFormatCode($format);

(The format code was obtained by setting a cell to accountancy then selecting custom in excel 2007).

However this causes an error when the sheet is opened in excel. Does anyone have any ideas about this? All I really need is a left justified pound sign with the number on the right of the cell.

Thanks,
Simon

 

Developer
Jul 21, 2009 at 3:39 AM

>> However this causes an error when the sheet is opened in excel.

I tried your code, and it worked with no errors. Maybe you have not saved your script as UTF-8 (no BOM) ? If you save as ISO 8859-1 then it will not work (because of the pound signs).

Jul 21, 2009 at 11:11 AM

Doh! - Thanks for that, changed to $format = utf8_encode('_-£* #,##0.00_-;-£* #,##0.00_-;_-£* "-"??_-;_-@_-'); and all's good :)