Skip to content
This repository has been archived by the owner on Jan 2, 2019. It is now read-only.

string convert to float error #1408

Open
salterping opened this issue Jun 20, 2018 · 0 comments
Open

string convert to float error #1408

salterping opened this issue Jun 20, 2018 · 0 comments

Comments

@salterping
Copy link

$PHPReader = new \PHPExcel_Reader_Excel2007(); $newFile = "520.xlsx"; $PHPExcel = $PHPReader->load($newFile); $currentSheet = $PHPExcel->getSheet(0); for ($rowIndex = 1; $rowIndex <= 100; $rowIndex ++) { $buyerNick = 'A' . $rowIndex; $buyerNickCell = $currentSheet->getCell($buyerNick)->getValue(); exit(var_dump($buyerNickCell)); }
520.xlsx

A1 is 84.4, the echo is 84.40000000000001

// Check for numeric values if (is_numeric($value) && $cellDataType != 's') { if ($value == (int)$value) $value = (int)$value; elseif ($value == (float)$value) $value = (float)$value; elseif ($value == (double)$value) $value = (double)$value; }
this code is convert string to float so 84.4 => 84.40000000000001

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant