csv文件的dateformat是“yyyy-mm-dd”在excel中打开时显示dd / mm / yyyy 我想在excel中显示原始格式
感谢
答案 0 :(得分:1)
从以下数据开始:
尝试运行像:
这样的宏Sub GetDatesFromCSV()
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;C:\Users\JamesRavenswood\Desktop\temp.csv", Destination:=Range("$A$1"))
.Name = "temp"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 437
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(5)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
Range("A:A").NumberFormat = "yyy-mm-dd"
End Sub