Hi Mark
Thank you for your response. I have tried adding:
I tried a few other tests to try to identify where the cause lies and got an interesting result. If I run an echo ROUND(96.239,2); on a blank php page the rounding works fine. However, once I include the phpexcel files, initialise a new instance and run the same pure PHP ROUND function it will make the same floating point error. So something during the initialising of a new phpexcel instance is causing the PHP ROUND function to behave differently... I'm not sure if this gives anyone any ideas?
Rounding error occurs:
Thank you for your response. I have tried adding:
$objPHPExcel->getActiveSheet()->getStyle('A1')->getNumberFormat()->setFormatCode("#,##0.00");
$objPHPExcel->getActiveSheet()->getStyle('A1')->getNumberFormat()->setFormatCode("0.00");
before and after setting the cell value, but with no success I'm afraid. I also tried using apostrophes rather than quotation marks around the format code. I am not sure if this is the correct approach for setting the mask as suggested or if you would suggest something else?I tried a few other tests to try to identify where the cause lies and got an interesting result. If I run an echo ROUND(96.239,2); on a blank php page the rounding works fine. However, once I include the phpexcel files, initialise a new instance and run the same pure PHP ROUND function it will make the same floating point error. So something during the initialising of a new phpexcel instance is causing the PHP ROUND function to behave differently... I'm not sure if this gives anyone any ideas?
Rounding error occurs:
require_once('phpexcel/Classes/PHPExcel.php');
// Create new PHPExcel object
$objPHPExcel = new PHPExcel();
echo "<br />".ROUND(96.239,2);
No Rounding error:require_once('phpexcel/Classes/PHPExcel.php');
echo "<br />".ROUND(96.239,2);
// Create new PHPExcel object
$objPHPExcel = new PHPExcel();
Tim