简体   繁体   中英

import comma separated numbers to excel from web

I am trying to import comma separated numbers in a cell in 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:

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? 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 . and excel will not treat my case 016448,016501,017612,01... etc as one long number.

If you plan on running the script "autonomasly" then just have those settings in a virtual machine where you run the script.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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