Leading 0 removed..

Topics: Developer Forum, User Forum
Aug 2, 2008 at 2:16 PM
Hey.

Im trying to read an excel2007 file.
I have a column with articlenumber, of which some start with a zero. "0073672" for example.
The cell is formatted as text in excel, so the 0's are there.
Thou when i read the file and output the numbers, the 0's are removed.

I use:
$objReader->setReadDataOnly(true);
echo $ws->getCell("A1")->getValue();

Any idea what im doing wrong?
Developer
Aug 2, 2008 at 7:16 PM
I think this may be a bug in the Excel2007 reader. It would probably be preferable to have correlation between the variable type for cell values in the PHPExcel object and the data type for the cell as set in the Excel document one is loading.

If this is urgent, a temporary fix for you may be to change in PHPExcel/Reader/Excel2007.php from this

if (is_numeric($value)) {

to this

if (is_numeric($value) && !(preg_match('/^0[0-9]+/', $value))) {

Related discussion:
http://www.codeplex.com/PHPExcel/Thread/View.aspx?ThreadId=31240