str = left(wscript.scriptfullname,instrrev(wscript.scriptfullname,"\")-1) '获取当前路径
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FileExists(str+"\RESULT.CSV") Then
If fso.FileExists(str+"\RESULT.xls") Then
fso.DeleteFile str+"\RESULT.xls", true
End If
strCsvFile = str+"\RESULT.CSV"
set objExcel = CreateObject("Excel.Application")
set Csvbook = objExcel.Workbooks.open(strCsvFile) '打开CSV文件
set Csvsheet = Csvbook.Worksheets(1) '取CSV文件的sheet
set Excelbook = objExcel.Workbooks.Add '新建EXCEL文件
set Excelsheet = Excelbook.Worksheets(1) '添加工作页
'获取CSV第一行列数
i=1
j=1
do while not isempty(Csvsheet.cells(i,j).value)
j=j+1
loop
k=j
'以下为复制数据
do while not isempty(Csvsheet.cells(i,1).value)
j=1
do while j<k
Excelsheet.cells(i,j).value=Csvsheet.cells(i,j).value
j=j+1
loop
i=i+1
loop
Excelbook.SaveAs str+"\RESULT.xls" '保存xls文件
wscript.echo str+"\RESULT.xls"+" 创建成功!"
'释放资源
Excelbook.close
Csvbook.close(false) '不保存对CSV文件的修改
objExcel.quit
else
wscript.echo str+"\export.csv"+" 不存在!"
end if
WScript.quit
[/code]