Leading Zero in a CSV File
Posted on 2008-10-22
My app creates a CSV file that the user will later double click to open it in Excel. The CSV file contains, among other info, a couple of "numeric" text fields (zip code is one). When the fields contain a leading zero, Excel seems to drop it.
A couple of caveats...
1. The users are, shall we say, less than tech-savvy so having them format the Excel columns every time the file is opened is out of the question.
2. The file will be opened by double clicking on it, so utilizing the Excel "text import" option is also out of the question.
3. One option I saw was to wrap the value in equals/quotes (like: ="<value>"). Excel retains this and will confuse the user if they attempted to edit the value.
Seems to me you used to be able to get around this by prepending an apostrophe, but that no longer seems to work, at least no in Excel 2003.
Any other valid options?