标题: [技术讨论] 测试VBS生成二维柱状图 [打印本页]
作者: yiwuyun 时间: 2014-12-31 08:23 标题: 测试VBS生成二维柱状图
- Dim objExcel,strArray(6)
- strPath=Left(WScript.ScriptFullName,InStrRev(WScript.ScriptFullName,"\"))
- Set objExcel=CreateObject("Excel.Application")
- objExcel.WorkBooks.Add()
- objExcel.DisplayAlerts=false
- objExcel.visible=true
- objExcel.SheetsInNewWorkBook=2
- col=1
- row=1
- strArray(0)="姓名"
- strArray(1)="数学"
- strArray(2)="外语"
- strArray(3)="历史"
- strArray(4)="化学"
- strArray(5)="生物"
- For col=1 to 6
- objExcel.Cells(1,col).value=strArray(col-1)
- Next
-
- For row=2 to 10
- objExcel.Cells(row,1).value=String(1,65)+CStr(row)
- Next
-
- objExcel.Range("B2:F10").Formula="=40+Int(Rand()*61)"
- objExcel.Range("A1:F10").Style.HorizontalAlignment=-4108
-
- Set objShape=objExcel.ActiveSheet.Shapes.AddChart(51)
- objShape.Chart.SetSourceData objExcel.Range("A1:F10"),2
- Set objShape=Nothing
-
- objExcel.ActiveSheet.SaveAs(strPath&"test.xlsx")
- Set objExcel=Nothing
- 'objExcel.Quit()
复制代码
作者: g495326 时间: 2014-12-31 09:58
回复 1# yiwuyun
弱弱的问下,excel.application 对象-哪里有带有例子的资料。
欢迎光临 批处理之家 (http://www.bathome.net/) |
Powered by Discuz! 7.2 |