custom cell format in excel 2003

Topics: Developer Forum, User Forum
Dec 20, 2012 at 9:12 PM
Edited Dec 21, 2012 at 8:38 AM

Hello Team,

I have simple excel(2003 .xls) file what I reading. But some cells have custom format type # ##0,00%.
When I reading with your app after I getting a faild value(110.2f)
I need the right value, How I get back the right value?

Here some example of cell value and the get values:

-17,65% - > 110.2f
5,20% -> 110.2f

Thanks for helping

Dec 21, 2012 at 4:16 PM
Edited Dec 21, 2012 at 4:17 PM

I solved this case:

$turnover_str = $workSheet->getCell('G'.$sor);
//output in browser: -0.22878905524141

but I need this format: -22,87

I make this function for the convert:

function conv_to_percent($str){ 
	$str = (int)$str * 100;
	$str = number_format($str, 2, ',', '');
return $str;}

Output in browser all result is 100  example when $str value is -0.22878905524141:

But I have created a clean php for this function and working fine(I have only this function):

print conv_to_percent("-0.22878905524141"); //output: -22,88

I tried (int), floatval($str) but problem is same. What I make a wrong?