- 论坛徽章:
- 0
|
用WHS就可以,也可以用Perl或者Python都有现成模块
- textFile = "d:\aaa.txt"
- excelFile = "d:\aaa.xls"
- Set fs = CreateObject("Scripting.FileSystemObject")
- Set f = fs.OpenTextFile(textFile, 1)
- Set objExcel = CreateObject("Excel.Application")
- Set oWB = objExcel.Workbooks.Add
- Set oSheet = oWB.ActiveSheet
- j = 1
- While not f.AtEndOfStream
- r = f.ReadLine
- data = Split(r, " ", -1)
- for i = 0 to UBound(data)
- oSheet.Cells(j, i + 1).value = data(i)
- next
- j = j + 1
- Wend
- f.Close
- objExcel.ActiveWorkbook.SaveAs(excelFile)
- objExcel.quit
复制代码
将上边代码保存为txt2xls.vbs, 执行
D:\>cscript txt2xls.vbs
Win2000下测试通过
[ 本帖最后由 slash001 于 2006-3-17 17:09 编辑 ] |
|