Importing to Excel from csv AND keep leading zeros

G

Guest

I have a script that saves a csv file and mails it to people as a report.
When people open the csv file using Excel the column of account numbers have
leading zeros. Not all but most.

How can I have them open or import to Excel and keep the leading zeros from
that column?
 
P

Pete_UK

Can you amend your script so that it saves the file with a .TXT
extension rather than a .CSV? (If not, then your users will have to
rename the file extension themselves).

Now with Excel running, use File | Open, select "All files *.*" as the
file type, locate your TXT file and click Open - Excel will
automatically take you into the Data Import Wizard. In the third
dialogue box of this, you can specify that you want data in a
particular column to be imported as Text - just highlight the column
and click Text. Do this for each column where you want to preserve
leading zeros, then click Finish.

Hope this helps.

Pete
 
G

Guest

Can you modify your script so that it produces a comma delimited file with
quotes (") as the text qualifier. Excel will automatically recognize the
quote as enclosing a string value and not a numeric one.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top