3

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...

3 Answers 3

1

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.

Sign up to request clarification or add additional context in comments.

Comments

1

Export / Import excel to mysql. DEAME3P

Comments

1

I think u want something like this

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

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.