开发者

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 f开发者_运维问答loat values end with .zero (.0) to print.

Please help me out...


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.


Export / Import excel to mysql. DEAME3P


I think u want something like this

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

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜