tags:

views:

211

answers:

1

I am generating a csv file from a PHP array. It opens just fine in Excel and OpenOffice Calc, however the data in one of the column are zip codes. Excel makes the cell formats of the column number general by default. This results in the leading 0 getting dropped in zip codes. Is there any way I can specify the cell formats within the CSV file?

+2  A: 

There is no way to specify the cell formats as such (by design), however to assure the zero is not lost, put quotes around the cell values and this will force them to be treated as strings.

eg.:

"Harry", "Potter", "12", "Achre", "Lane", "5000"
"Mary", "Shelley", "14", "Wilson", "Way", "0202"
Russell
Thanks, Russel. Unfortunately this didn't work either.
Someone