该程序是用EXCEL对象生成一张三维柱状图,再输出一个GIF文件,生成图表是成功了,但相关的参数却设置无效,不管我设什么参数,如图片的标题,图片的大小,始终都是无标题,图片大小也无法调整。
还有个问题,要想设置背景颜色、柱体颜色用什么参数?Sub ExportPicture(dataArray, virtualFilePath, nType, datacaption)Dim excelapp '' As New excel.Application
Dim excelwbk '' As excel.Workbook
Dim excelcht '' As excel.Chart
Dim excelsht ''As excel.Worksheet
Dim idx, idy, idz, ftype, usedData, totalcount, inittype, count: count = 1
On Error Resume NextSet excelapp = CreateObject("Excel.Application")
Set excelwbk = excelapp.Workbooks.Add()
Set excelcht = excelwbk.Charts.Add()
Set excelsht = excelwbk.Worksheets.Add()
inittype = nType
ftype = "gif"
For idx = LBound(dataArray, 1) To UBound(dataArray, 1)
For idy = LBound(dataArray, 2) To UBound(dataArray, 2)
excelsht.Cells(idx + 1, idy + 1) = dataArray(idx, idy)
Next
For idz = LBound(dataArray, 3) To UBound(dataArray, 3)
excelsht.Cells(idx + 2, idy + 2) = dataArray(idx, idy)
NextNextSet usedData = excelsht.UsedRange
excelcht.Activate
With ActiveChart
.HasLegend = True
.Type = xlLine
.HasTitle = True
.ChartTitle.Text = datacaption
.Height = 50
.weith = 70
End With
excelcht.SeriesCollection.Add usedData
excelcht.ApplyCustomType nType
excelcht.Export virtualFilePath, ftype
excelsht.Close False
excelwbk.Close False
Set usedData = Nothing
Set excelcht = Nothing
Set excelwbk = Nothing
Set excelapp = Nothing
End Sub
还有个问题,要想设置背景颜色、柱体颜色用什么参数?Sub ExportPicture(dataArray, virtualFilePath, nType, datacaption)Dim excelapp '' As New excel.Application
Dim excelwbk '' As excel.Workbook
Dim excelcht '' As excel.Chart
Dim excelsht ''As excel.Worksheet
Dim idx, idy, idz, ftype, usedData, totalcount, inittype, count: count = 1
On Error Resume NextSet excelapp = CreateObject("Excel.Application")
Set excelwbk = excelapp.Workbooks.Add()
Set excelcht = excelwbk.Charts.Add()
Set excelsht = excelwbk.Worksheets.Add()
inittype = nType
ftype = "gif"
For idx = LBound(dataArray, 1) To UBound(dataArray, 1)
For idy = LBound(dataArray, 2) To UBound(dataArray, 2)
excelsht.Cells(idx + 1, idy + 1) = dataArray(idx, idy)
Next
For idz = LBound(dataArray, 3) To UBound(dataArray, 3)
excelsht.Cells(idx + 2, idy + 2) = dataArray(idx, idy)
NextNextSet usedData = excelsht.UsedRange
excelcht.Activate
With ActiveChart
.HasLegend = True
.Type = xlLine
.HasTitle = True
.ChartTitle.Text = datacaption
.Height = 50
.weith = 70
End With
excelcht.SeriesCollection.Add usedData
excelcht.ApplyCustomType nType
excelcht.Export virtualFilePath, ftype
excelsht.Close False
excelwbk.Close False
Set usedData = Nothing
Set excelcht = Nothing
Set excelwbk = Nothing
Set excelapp = Nothing
End Sub
解决方案 »
- win7下使用vsflexgrid控件滚动条疑难杂症
- AddressOf的问题
- 控件调用那种方法好
- 在sql中,如果想将表t1字段d1的数值全部复制到表t2字段d2下(d1和d2的类型一样,记录数不一样),怎样写语句呀?
- 请问运算这题的具体是怎样的?使用VB中断功能仍然有些不明白的地方
- VB中怎么用数据库啊?大家能给个建议或者推荐本书吗?
- 请问为什么我调试webclass的时候总是提示“系统找不到指定路径”啊?
- 一个很简单的问题~~~
- 我想请教:在串行通信时,什么情况下用WaitForSingleObject(hMutex,1)这个函数?
- 我不懂
- 如何实现让窗口可以最小化,但又不让用户调整窗口的大小?
- 数据查询的执行效率的问题?????????????????
另外office也带了一个Microsoft Graph object libary先引用以后就可以用了,具体的用法参看office的相关帮助。
如果用 mschart 或 同类的控件还更方便