简体   繁体   English

导入逗号分隔的数字以从Web到Excel

[英]import comma separated numbers to excel from web

I am trying to import comma separated numbers in a cell in excel. 我正在尝试在Excel的单元格中导入逗号分隔的数字。 It looks like this on web: 在网络上看起来像这样:

000002678,000002737,000002827,000004326,000008528

But as soon as I import it in excel it transforms to following: 但是,一旦我将其导入excel,它就会转换为以下内容:

2,678,000,002,737,000,000,000,000,000,000,000,000,000

How can I maintain the format like it is on web and not treat it as one big number? 如何保持网络上的格式,而不将其视为一个大数字?

With ActiveSheet.QueryTables.Add(Connection:= _
    "URL;http://localhost:65076/TestData", Destination:=Range( _
    "$A$1"))
    .Name = "Test"
    .FieldNames = True
    .RowNumbers = False
    .FillAdjacentFormulas = False
    .PreserveFormatting = True
    .RefreshOnFileOpen = False
    .BackgroundQuery = True
    .RefreshStyle = xlInsertDeleteCells
    .SavePassword = False
    .SaveData = True
    .AdjustColumnWidth = True
    .RefreshPeriod = 0
    .WebSelectionType = xlAllTables
    .WebFormatting = xlWebFormattingNone
    .WebPreFormattedTextToColumns = True
    .WebConsecutiveDelimitersAsOne = True
    .WebSingleBlockTextImport = False
    .WebDisableDateRecognition = False
    .WebDisableRedirections = False
    .Refresh BackgroundQuery:=False
End With

@PeterL or user793468 Did you ever solve this? @PeterL或user793468您是否解决了这个问题? Because i have the exact same problem and the only solution i found was a workaround (that actually can work!) 因为我有完全相同的问题,并且我发现的唯一解决方案是一种解决方法(实际上可以工作!)

Set Windows Region and Language settings: "Decimal Settings" from , to . 设置Windows区域和语言设置:从到的“十进制设置”。 and excel will not treat my case 016448,016501,017612,01... etc as one long number. 并且excel不会将我的情况016448,016501,017612,01 ...等视为一个长数字。

If you plan on running the script "autonomasly" then just have those settings in a virtual machine where you run the script. 如果计划“自动”运行脚本,则只需在运行脚本的虚拟机中进行设置即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM