Home » excel » PHP MySQL Excel to xls?

PHP MySQL Excel to xls?

Posted by: admin April 23, 2020 Leave a comment


This my example code:

$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…

How to&Answers:

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.


I think u want something like this




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