Leading zeros being dropped

May 1, 2010 at 6:39 PM

I have a vendor who exports records to xls and then uploads them to my site where they are processed using phpexcel.

Somewhere either when he exports or when I import leading zeros are being dropped. For example from zipcodes.

Anyone have any idea if this is a setting in PHPExcel?


May 1, 2010 at 8:16 PM

Take a look at the xls file that you receive from your vendor before allowing PHPExcel to process it, and see if the values have leading zeroes at that point. If they have, then you know it's the PHPExcel import that's losing the zeroes.

If the value is being treateds as a number, then either cast it to a string and replace the leading zeroes in PHP, or look at the Excel format mask options.

Sep 15, 2011 at 5:50 PM

I know this discussion is old, but it applies directly (and I hope someone sees it.

I import Excel into my PHP app using PHPExcel (1.7.6).  There are text cells with leading zero(s).

Upon traversing the imported sheet,  getValue() and getFormattedValue() both lose the leading zero(s).

I have tried various formats for the cells prior to importing (General, Text) and in every instance, there is no leading zero(s).

I am really at a loss as previous research has shown that since 1.7.5 the getFormattedValue() should retain this.

Any help is surely appreciated.