percent format

Nov 17, 2011 at 12:11 PM

Hello all,

I don't manage to format a range of cells in percent format like this : 19.62%

I have tried FORMAT_PERCENTAGE_00 but it gives me result 19.00%


Thanks for your help


Nov 17, 2011 at 3:52 PM

Try something like...

$format_percent = array(
	'numberformat' => array(
		'code' => '0.00%',


Nov 19, 2011 at 7:13 AM
Edited Nov 19, 2011 at 7:13 AM

Thanks Scott for your help.

But while trying thisI got a Fatal error: Call to a member function getActiveSheet() on a non-object in app/vendors/excel/PHPExcel/Style/NumberFormat.php on line 175


I have put that code on the file named NumberFormat.php.

Nov 19, 2011 at 8:05 AM

Got the solution.

In the file AdvancedValueBinder.php, located at vendors/excel/PHPExcel/Cell folder we have a function bindValue().

There while Checking for percentage section the $value is type casted into integer format thus it was not taking the decimal values.

I just made it type casted into float type.

And it WORKS :)

Nov 21, 2011 at 5:46 PM

Dunno why the above did not work, but I had edited the same thing in my source actually but to fix an issue with huge integers. :) I hope this gets fixed officially.

Jun 8, 2013 at 4:22 PM
Edited Jun 8, 2013 at 4:25 PM
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue($celula, (float)$c9.'%');