attribut of a cellule

Feb 17, 2009 at 1:47 PM
I work on a tool to automatize the generation of a excell file from mysql.
I have got this problem.
I  write :         $objPHPExcel->getActiveSheet()->getStyle($cel)->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_PERCENTAGE_00);
It works fine when you open excel
if i write       
     $format = "PHPExcel_Style_NumberFormat::FORMAT_PERCENTAGE_00"

I have an error file error : some number formats may have been lost. and then all the numerics field are characters.
Ok there is an other way to do it ( i create a fonction and make a switch). I just want to know if it's normal, and if it will be the case for all the getstyle attribut and etc.

Feb 17, 2009 at 5:14 PM
$format = PHPExcel_Style_NumberFormat::FORMAT_PERCENTAGE_00;

without the quotes
Feb 18, 2009 at 1:48 PM
Edited Feb 18, 2009 at 2:25 PM
ok. but it doesn't solve my problem to memorize the format in a table.
As it is a constant, i should be able to replace the constant by the value.but it doens't work also.
like :
$format = '0.00';
I have a look in the different class and i saw that you use the constant and not the value of the constant
So it will never work
I think that i have no choice. I have to create a function with a switch for each data (style, tc) that i want to memorize in a table

Feb 18, 2009 at 10:27 PM
All four of the following should work in exactly the same way



$format = PHPExcel_Style_NumberFormat::FORMAT_NUMBER_00;

$format = '0.00';

Feb 18, 2009 at 10:31 PM
Edited Feb 18, 2009 at 10:32 PM
This sounds a bit mysterious. Do you have a complete example of what is not working?

It should make no difference whether you use PHPExcel_Style_NumberFormat::FORMAT_PERCENTAGE_00 or '0.00%'

Edit: markbaker beat me to it
Feb 19, 2009 at 12:19 PM
ok I found my error. Too much '. Very stupid error.
Like this its very good, i can create specific format and replace the simple conditional formating  for xl 2003

Thanks again for your help and this very good tool.