Stop Excel from automatically converting certain text values to dates

前端 未结 30 2641
别跟我提以往
别跟我提以往 2020-11-22 04:16

Does anyone happen to know if there is a token I can add to my csv for a certain field so Excel doesn\'t try to convert it to a date?

I\'m trying to write a .csv fil

相关标签:
30条回答
  • 2020-11-22 04:51

    Okay found a simple way to do this in Excel 2003 through 2007. Open a blank xls workbook. Then go to Data menu, import external data. Select your csv file. Go through the wizard and then in "column data format" select any column that needs to be forced to "text". This will import that entire column as a text format preventing Excel from trying to treat any specific cells as a date.

    0 讨论(0)
  • 2020-11-22 04:51

    EASIEST SOLUTION I just figured this out today.

    • Open in Word
    • Replace all hyphens with en dashes
    • Save and Close
    • Open in Excel

    Once you are done editing, you can always open it back up in Word again to replace the en dashes with hyphens again.

    0 讨论(0)
  • 2020-11-22 04:55

    In Excel 2010 open a new sheet. On the Data ribbon click "Get External Data From Text". Select your CSV file then click "Open". Click "Next". Uncheck "Tab", place a check mark next to "Comma", then click "Next". Click anywhere on the first column. While holding the shift key drag the slider across until you can click in the last column, then release the shift key. Click the "text" radio button then click "Finish"

    All columns will be imported as text, just as they were in the CSV file.

    0 讨论(0)
  • 2020-11-22 04:57

    I had a similar problem and this is the workaround that helped me without having to edit the csv file contents:

    If you have the flexibility to name the file something other than ".csv", you can name it with a ".txt" extension, such as "Myfile.txt" or "Myfile.csv.txt". Then when you open it in Excel (not by drag and drop, but using File->Open or the Most Recently Used files list), Excel will provide you with a "Text Import Wizard".

    In the first page of the wizard, choose "Delimited" for the file type.

    In the second page of the wizard choose "," as the delimiter and also choose the text qualifier if you have surrounded your values by quotes

    In the third page, select every column individually and assign each the type "Text" instead of "General" to stop Excel from messing with your data.

    Hope this helps you or someone with a similar problem!

    0 讨论(0)
  • 2020-11-22 04:58

    I have found that putting an '=' before the double quotes will accomplish what you want. It forces the data to be text.

    eg. ="2008-10-03",="more text"

    EDIT (according to other posts): because of the Excel 2007 bug noted by Jeffiekins one should use the solution proposed by Andrew: "=""2008-10-03"""

    0 讨论(0)
  • 2020-11-22 04:58

    Working off of Jarod's solution and the issue brought up by Jeffiekins, you could modify

    "May 16, 2011"
    

    to

    "=""May 16, 2011"""
    
    0 讨论(0)
提交回复
热议问题