vb创建xls表,并写入内容
Set ExcelApp = CreateObject("Excel.Application") '创建EXCEL对象
Set ExcelBook = ExcelApp.Workbooks.Add
Set ExcelSheet = ExcelBook.Worksheets(1) '添加工作页
ExcelSheet.Activate
ExcelApp.DisplayAlerts = False
ExcelSheet.Name="sheet1"
ExcelSheet.Range("A1").Value = 100 '设置A1的值为100
ExcelBook.SaveAs "d:\test.xls" '保存工作表
msgbox "d:\test.xls创建成功!"
ExcelBook.close
set excelApp=nothing
set ExcelBook=nothing
set ExcelSheet=nothing
将以上代码copy到记事本存为"writexls.vbs"文件,可运行测试
读execel文件
Set ExcelApp = CreateObject("Excel.Application") '创建EXCEL对象
Set ExcelBook = ExcelApp.Workbooks.open("d:\test.xls")
Set ExcelSheet = ExcelBook.Worksheets(1)
msgbox ExcelSheet.Range("A1").Value
将以上代码copy到记事本存为"readxls.vbs"文件,可运行测试