Quantcast
Channel: PHPExcel Forum Rss Feed
Viewing all articles
Browse latest Browse all 2707

New Post: ROUND Function getCalculatedValue() error

$
0
0
Hi Mark

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

Viewing all articles
Browse latest Browse all 2707

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>