- Set fso = CreateObject("Scripting.FileSystemObject")
- Set ExcelApp = CreateObject("Excel.Application")
- ExcelApp.Visible = True
- Set objBook= ExcelApp.Workbooks.Add
- str = split("Order ID|Purchase Date|Shipping Service|Buyer Name|Buyer E-mail", "|")
- ExcelApp.WorkSheets(1).Activate
- For i=0 to Ubound(str)
- ExcelApp.Cells(1, i+1) = str(i)
- Next
-
- i=1
- Set f = fso.OpenTextFile("文本.txt", 1)
- Do While f.AtEndOfStream <> true
- line = f.ReadLine
- If InStr(line, str(0)) >0 Then i=i+1:ExcelApp.Cells(i, 1) = split(line, ":")(1)
- If InStr(line, str(1)) >0 Then ExcelApp.Cells(i, 2) = split(line, ":")(1)
- If InStr(line, str(2)) >0 Then ExcelApp.Cells(i, 3) = split(line, ":")(1)
- If InStr(line, str(3)) >0 Then ExcelApp.Cells(i, 4) = split(line, ":")(1)
- If InStr(line, str(4)) >0 Then ExcelApp.Cells(i, 5) = split(line, ":")(1)
- Loop
-
- objBook.SaveAs(fso.GetFolder(".").Path&"\新建.xls")
- objBook.Close
- ExcelApp.Quit
复制代码
|