How do I format a cell for money?

Aug 3, 2009 at 10:19 PM

I'm trying to format cells for money amounts with 0.00 type precision, but can't find it... figuring it's in the style method?

Still looking, but some quick help would be great.

Loving this package more and more. We tried the PEAR package first and not to cast aspersions on anyone, but this one is just top notch over that one.

Developer
Aug 3, 2009 at 10:33 PM

For a start:

$sheet = $excel->getActiveSheet();
$sheet->getCell('A1')->setValue(12345.67);
$sheet->getStyle('A1')->getNumberFormat()->setFormatCode('0.00');

Also download the latest source code, and make sure to check out section "Number Formats" in the "PHPExcel Developer Documentation". There you will find some tips how to get some of the more advanced things working. This information is not included in the documentation with PHPExcel 1.6.7.