Murugesh
Murugesh

Reputation: 820

PHP MySQL Excel to xls?

This my example code:

$objPHPExcel->setActiveSheetIndex(0);
$objPHPExcel->getActiveSheet()->SetCellValue('A2', '1.0');
$objPHPExcel->getActiveSheet()->SetCellValue('B2', '0.0');
$objPHPExcel->getActiveSheet()->SetCellValue('C2', '1.2');
$objPHPExcel->getActiveSheet()->SetCellValue('D2', '100');

I am getting in excel sheet is round off values for A2->1 and B2->0, What I need to output in excel sheet is A2->1.0 and B2->0.0. I need the float values end with .zero (.0) to print.

Please help me out...

Upvotes: 3

Views: 478

Answers (3)

Ricardo Origin
Ricardo Origin

Reputation: 175

I think u want something like this

$objPHPExcel->getActiveSheet()->getStyle('D1')->getNumberFormat()->setFormatCode('###.00');

I use it on my project, any doubts, ask away

Upvotes: 1

ObjetivoPHP
ObjetivoPHP

Reputation: 11

Export / Import excel to mysql. DEAME3P

Upvotes: 1

Jim Garrison
Jim Garrison

Reputation: 86774

You need to set the display format of the cells to Number. The default in Excel is General, which will display the values as you describe. I don't know if the PHP Excel interface will let you set the cell format, but that's where you should start.

EDIT: According to the PHPExcel website it supports setting cell formats. Read the docs to find out how to set the appropriate format.

Upvotes: 1

Related Questions