Solved

How can I save an Excel spreadsheet to CSV and preserve the format?

Posted on 2014-12-24
9
67 Views
Last Modified: 2015-01-03
Spreadsheet with 2 columns, A and B.

Column A contains Item numbers, many of which start with leading zeros.  ie 00001,  00002, etc...
When you save the Excel spreadsheet to CSV it removes the leading zeros and the numbers show up only as 1, 2 etc..  it must keep the leading zeros.
0
Comment
Question by:100questions
  • 2
  • 2
  • 2
  • +3
9 Comments
 
LVL 3

Expert Comment

by:Glenn M
ID: 40516562
CSV is typically just ASCII text so there's no way I'm aware of to preserve any formatting. Even if you format the cells in Excel as text when you save as CSV the leading zeros will get stripped out.
0
 
LVL 35

Expert Comment

by:Joseph Daly
ID: 40516572
This is correct. CSV files will not save formatting, spacing, font, color, etc. In its simplest form it is data in plain text seperated by commas. If you want those options you need to keep it in xls or xlsx format.
0
 
LVL 45

Expert Comment

by:aikimark
ID: 40516607
If you format the cells/columns as text, you should be able to output a CSV file with the leading zeros preserved.

See the attached CSV for an example
Q-28586471.csv
0
 
LVL 3

Expert Comment

by:Glenn M
ID: 40516626
That's true aikimark. We don't know what application the posted will be opening the CSV file in. I know in Excel it will treat it as a general format and strip the zeros.
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 45

Expert Comment

by:aikimark
ID: 40516671
If saved with a .txt file extension, Excel might be inclined to treat the column as text, especially if it is quote delimited.
0
 
LVL 23

Expert Comment

by:DanCh99
ID: 40517288
If you can start your text with an ' (apostrophe) character, you can then add as many leading zeros as you want, and if saving to CSV, then the formatting should be preserved.

HOWEVER, if you open the CSV in Excel again, the formatting is lost - even with double-quotes " around them.

So, it seems to be a one-way trip.  Does this work for you?  Why do you need ad CSV, please? Where's the data going....?
0
 
LVL 21

Expert Comment

by:Ejgil Hedegaard
ID: 40517966
It is not a one way trip.
As alkimark says
Excel might be inclined to treat the column as text
If the csv file is imported to Excel using the data import wizard, you can define the column to be treated as text, and the leading zeros are preserved.
0
 

Accepted Solution

by:
100questions earned 0 total points
ID: 40521918
Solution:  When saving it to a csv, do not open that saved file with Excel, open it with Notepad.  The format will not be disrupted to the leading zeros.
0
 

Author Closing Comment

by:100questions
ID: 40528939
This works.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

What is a Form List Box? (skip if you know this) The forms List Box is the alternative to the ActiveX list box. If you are using excel 2007, you first make sure you have a developer tab (click the Orb)->"Excel Options"->Popular->"Show Developer tab…
Sparklines have been introduced with Excel 2010 and are a useful tool for creating small in-cell charts, used for example in dashboards. Excel 2010 offers three different types of Sparklines: Line, Column and Win/Loss. What it does not offer is a…
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now