How to stop Excel from Auto-formatting and making it work like a number crunching program

154,216

Solution 1

You need to specify in the csv file that it is text. You do this by putting your number in quotes and preceeding with and equal sign, eg:

="001145",="55666",="02133"

The easiest way to do this would be to do a find-replace on , with ",=", replacing end of lines (you might need to use an advanced editor like Notepad++ for this) with "\r\n=" and doing the start and end of the file manually.

Solution 2

  1. Change the file extension from ".csv" to ".txt" on the file you are having problems with.
  2. Open excel by itself. Don't click on the file to open it.
  3. Click "Open", change the file types to look for from "All Excel Files" to "All Files"
  4. Find your file and click open. Since Excel doesn't auto format txt, it will then take you thru the wizard.
  5. Makes sure the "Delimited" radio button is selected. Click the "next" button.
  6. Check the "comma" delimiter box and keep hitting the "next" button until you SEE (but don't click on it) the finish button.
  7. scroll thru each column in the spreadsheet, highlight each column(s) you want to manually format and change the format to "text".
  8. Click the finish button.

Solution 3

Install OpenOffice from Oracle and do the same with OpenOffice's CSV format and it works.

I've had this problem in Windows 7 Pro with Excel 2010. I used to be able to copy Outlook contacts to Excel, save as CSV and import to Gmail and Android (the mobile numbers with leading zeros and + signs).

Solution 4

To add to @Jon's answer from this question, I had a CSV file that had several columns that had leading zeros and longer numbers that would either lose the leading zero or convert the long number to scientific notation, or both, when imported.

The only way I could fix was to first format all of the cells in the empty sheet to Text, by using the following steps:

  1. Select all the cells in the sheet:

enter image description here

  1. Change the format of every cell:

enter image description here

After formatting all of the sheet cells to be Text, then I could import the CSV using the following steps:

  1. From the Data tab, click From Text:

enter image description here

  1. Select your .txt or .csv file and click Import

  2. Select Delimited and click `Next:

enter image description here

  1. Select the appropriate delimiter (I chose Comma) and deselect any others that don't apply, then click Next:

enter image description here

  1. Scroll to the right to find the column(s) that need(s) to be formatted as Text to retain leading zeros and to prevent scientific notation. Click the column (it should darken), then select Text in the option list. Be sure to select all columns that need to be correctly formatted:

enter image description here

  1. Then click Finish. If you scroll to the columns that you formatted, you'll see that all leading zeros are retained and that long strings of numbers are not in scientific notation.

Hope that helps!

Solution 5

Right-click on the cells containing your data, and click on the Format cells... menu entry. Then, in the first tab ("Number"), change the category from General to Text. This will prevent Excel from automatically formatting those cells as numbers, and thus removing the leading zeroes (which are meaningless in the context of numerical analysis, but very meaningful when dealing with product IDs).

If the data is being imported and parsed as numbers, you need to use the Data Import wizard, and set each column type to "Text" instead of "General". Then, do the same thing with the cells, and then save your Excel workbook.

Share:
154,216

Related videos on Youtube

Sammaye
Author by

Sammaye

Updated on September 18, 2022

Comments

  • Sammaye
    Sammaye over 1 year

    I have a real problem with Excel in csv files where it is formatting numbers in certain ways and I cannot seem to get Excel to display the data right no matter what I do.

    Imagine I have a colum called "Product Reference". Within that column I have many IDs of the type:

    • 001145
    • 55666
    • 02133

    Whenever I open the Excel file it formats these numbers to be:

    • 1145
    • 55666
    • 2133

    Which is totally wrong. When I highlight the column and format it as text the previous 0's at the beginning of the numbers do not return.

    In an attempt to solve this I even made the csv file a text file first and then imported the file into Excel and specifically told it to not format the numbers by making it text format within the import but it still formats the numbers wrong when I close it and open it again due to the fact that csv cannot define types so Excel auto saves the file as pure garbage.

    Has anyone found a way around this and could help me out?

    Thanks,

    • Excellll
      Excellll over 12 years
      As far as I know, the only way to get Excel to faithfully render a CSV is to import it as text, the way you described.
    • Excellll
      Excellll over 12 years
      You don't have to make the CSV a text file though. The Import from Text File feature works for CSV files too. You just have to specify that you have comma delimiters.
  • Excellll
    Excellll over 12 years
    CSV files do not retain formatting. This isn't going to help.
  • Breakthrough
    Breakthrough over 12 years
    @Excellll obviously, it's just a bunch of comma-seperated ASCII characters. By default, Excel marks cell formats as General and attempts to interpret the value (numbers, dates, anything) so it can be used with formulas (as plain text usually cannot). You need to manually tell Excel to interpret the value as plain-text so it does not convert it automatically.
  • Sammaye
    Sammaye over 12 years
    Yea would work if Excel didn't "auto-save" the formatting of fields :( I need Excel to act the same way as any other CSV opener/Programming Language.
  • Sammaye
    Sammaye over 12 years
    I have tried that, Excel defaults it back when you open the converted Excel file. So I import from TXT to Excel and tell it in there to display as text, close the file and open it and Excel defaults back to number format for the fields hiding their true value and I am right back at sq one.
  • Sammaye
    Sammaye over 12 years
    Nice :) I'll give this a try and report back
  • Excellll
    Excellll over 12 years
    @Breakthrough, sorry I didn't express what I meant. As you said in your comment, when a CSV is opened in Excel, Excel will apply General formatting to all the data. At this point, the text (i.e. leading zeros) that is actually saved in the CSV file cannot be retrieved by Excel. The point is that once you've opened the CSV in Excel, it's too late to change the formatting.
  • Jack
    Jack almost 9 years
    This is a good, hassle-free way to solve the problem.
  • dinesh ygv
    dinesh ygv over 8 years
    You saved my day!
  • Vuongg
    Vuongg almost 3 years
    I have try this way and I think this is the only way to do, and the more important that it still keeps csv as original csv and not changing it to a kind of csv for only excel (no formula). Thank you a lot.
  • Vuongg
    Vuongg almost 3 years
    With this one, csv is not csv anymore. :) Kindly note the file won't be use for any other software which reads csv without Excel technique (can't read formula). BTW, it works if the expectation is: csv is only for Excel-able software.