Displaying Formatted Percentages

Topics: Developer Forum, User Forum
Dec 13, 2007 at 4:45 PM
Hi,

I've just made a faily complex spreadsheet using PHPExcel - definately a great set of PHP classes!

What I'm struggling with is changing the format of the display of the cells.

For example, I have a column that has a percentage value in it (currently displayed as a decimal < 1). How can I make this cell display as a percentage, rather than a decimal?

Thanks in advance!
Dave
Dec 13, 2007 at 4:57 PM
Edited Dec 13, 2007 at 4:57 PM
I've just found what I needed...

This will do the job:

$objPHPExcel->getActiveSheet()->getStyle('D2')->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_PERCENTAGE_00);


eckstac wrote:
Hi,

I've just made a faily complex spreadsheet using PHPExcel - definately a great set of PHP classes!

What I'm struggling with is changing the format of the display of the cells.

For example, I have a column that has a percentage value in it (currently displayed as a decimal < 1). How can I make this cell display as a percentage, rather than a decimal?

Thanks in advance!
Dave