PHP MySQL Excel for xls?

This is my sample 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 get rounded values ​​for A2->1and in the excel sheet B2->0, and what I need for output in the excel sheet is A2->1.0and B2->0.0. I need float values ​​to end with .zero ( .0) for printing. A.

Please help me...

+3
source share
3 answers

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

EDIT: - PHPExcel, . , , .

+1

/ Excel mysql. DEAME3P

+1

I think you want something like this

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

I use it in my project, any doubts, I apologize

+1
source

Source: https://habr.com/ru/post/1723961/


All Articles