PHPExcel Accounting Formats

$objPHPExcel->getActiveSheet()->getStyle('C1')->getNumberFormat()->setFormatCode("#,##0.00");

or use

$objPHPExcel->getActiveSheet()->getStyle('C1')->getNumberFormat()->setFormatCode("#.##0,00");

Set in getStyle CELL.


I reverse engineered the format code from an existing spreadsheet using PHPExcel and got this:

_("$"* #,##0.00_);_("$"* \(#,##0.00\);_("$"* "-"??_);_(@_)

This is the code Excel places on the cell when you select the "Accounting" format... or click that "$" toolbar button in Excel 2007.

If you didn't need currency symbol :

->setFormatCode("_(* #,##0.00_);_(* \(#,##0.00\);_(* \"-\"??_);_(@_)");

Tags:

Phpexcel