NYCPHP Meetup

NYPHP.org

[nycphp-talk] Fw: PHP form to MS Excel file

DeWitt, Michael mjdewitt at alexcommgrp.com
Wed Sep 8 12:42:43 EDT 2004


I have found that Excel (97 for sure) will open a tab delimited file whose
extension is XLS or CSV without any dialog or complaint. This is good and
bad as the Excel import dialog screens for delimited (TXT) files allows you
to set column data types appropriately.  

Excel tries to determine the column's datatype automatically and can get
confused if it checks the first row's data and sees a number in a given
column it assumes the whole column is numbers and will drop character data.


This conversion issue happens all of the time with zip codes where preceding
zeros are dropped, i.e., 02134 becomes 2134 and Canadian/foreign postal
codes get converted to a numeric only value.

The workaround is to make sure you have a column heading row, or insert a
row of character data (to be later deleted) as the first row and all of your
data will be preserved.

Mike

  



More information about the talk mailing list