[英]QueryTables problem with scientific notation
I'm trying to import data from a text file, there is no problem with that, the code runs and the data is imported but not correctly.我正在尝试从文本文件中导入数据,这没有问题,代码运行并且数据被导入但不正确。 I have text files with this type of numbers: 1.3309884e-13
我有这类数字的文本文件: 1.3309884e-13
When I'm importing the values, Excel is not taking the correct negative exponent and is returning 1.3309884e-5
and similar.当我导入这些值时,Excel 没有采用正确的负指数,而是返回1.3309884e-5
和类似的值。 The code is this:代码是这样的:
Dim ws As Worksheet, strFile As String
Set ws = ActiveWorkbook.Worksheets("DEPOSITION BC")
strFile = Application.GetOpenFilename("Text Files (*.csv),*.csv", , "Please select Black Carbon Dry Deposition bin 01 file (BCDP01)")
With ws.QueryTables.Add(Connection:="TEXT;" & strFile, _
Destination:=ws.Range("C5"))
.TextFileParseType = xlDelimited
.TextFileDecimalSeparator = "."
.TextFileCommaDelimiter = True
.TextFileStartRow = 23
.RefreshStyle = xlOverwriteCells
.Refresh
End With
I don't know how to avoid this problem.我不知道如何避免这个问题。
I've already found the conflict when importing.导入时我已经发现了冲突。 If I also set the thousands separator, the problem is solved:如果我还设置了千位分隔符,问题就解决了:
Dim ws As Worksheet, strFile As String
Set ws = ActiveWorkbook.Worksheets("DEPOSITION BC")
strFile = Application.GetOpenFilename("Text Files (*.csv),*.csv", , "Please select Black Carbon Dry Deposition bin 01 file (BCDP01)")
With ws.QueryTables.Add(Connection:="TEXT;" & strFile, _
Destination:=ws.Range("C5"))
.TextFileParseType = xlDelimited
.TextFileDecimalSeparator = "."
.TextFileCommaDelimiter = True
.TextFileStartRow = 23
.TextFileThousandsSeparator = False
.RefreshStyle = xlOverwriteCells
.Refresh
End With
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.