Phpexcel reads the number abnormal problem in excel

Before reading, in order to avoid the inconsistency of the excel data format, the cell format was changed to text, and the numbers in the file were all in text format.
Insert picture description here
However, as a result of reading, php automatically converts the numbers to float format. However, the pain is that in the same data format, some individual numbers are converted into a long string!
Insert picture description here
That's no way, then round up to one decimal place, it can only be troublesome.
But , damn it, round() doesn't work at all, it's still a long list.
Baidu checked it, and it was said that it was a php precision problem. Set ini_set('precision',-1) . This is to be tested.
I used the second method: the
principle should be that the binary problem of the underlying operation
can be solved by this method: sprintf( "%.2f",83.59999999999999); This is to retain 2 decimal places. If you want to keep one, just %.1f

Reading data is an object, causing an error

Insert picture description here
Solution

$val= $objPHPExcel->getActiveSheet()->getCell("C".$i)->getValue();
		    		
if (is_object($val)) {  			 
   $val = $val->__toString();
}

Guess you like

Origin blog.csdn.net/u012830303/article/details/88568928