Sunday, April 5, 2009

Microsoft Excel Leading Zeros on CSV import.

I've seen this question posed on various forums and for the most part, the answer is always something beyond a direct answer to the simple question of "how can I have Excel open a csv file and keep the leading zeros in a column intact?". Most of answers give a solution that calls for some level of manual manipulation beyond what is the intent of the question.

In my case, I wanted to create a comma delimited file on a mainframe and have the mainframe send out the file as an email attachement via SMTP. I wanted the said attachment to be a csv attachment that could be clicked on by the recipient to automatically launch Excel with the contents of the attachment. I didn't want the user to have to save a text file and import, or run some kind of macro, or mess around with text to columns, etc. I just wanted the user to be able to click on the file to launch the csv file in Excel, while keeping the leading zeros. Period.

What worked for me was formating the data as ="0098765".

2 Comments:

Anonymous Anonymous said...

Thank you for the simple solution to this annoying issue.

Regards,
Martin

August 3, 2009 at 11:36 PM  
Anonymous Anonymous said...

I have been looking for this simple but perfect solution for months. It was like a dream reading your post. Why doesn't anyone else on the WEB seem to know this?

October 26, 2009 at 1:48 PM  

Post a Comment

Subscribe to Post Comments [Atom]

<< Home