|
|
发表于 2004/4/19 16:37:12
|
显示全部楼层
数据导到excel同时生成图像
Sub Click(Source As Button)
'On Error ErrOLECantCreate Goto errh
On Error 207 Goto errh
Dim xlapp As Variant 'declare variable to hold the reference
Dim buttonhide As String
Dim workspace As New notesuiworkspace
Dim uidoc As notesuidocument
Set uidoc=workspace.Currentdocument
Set xlapp=createobject("excel.application")
xlapp.workbooks.add
xlapp.visible=True
For i=2 To 11
xlapp.range("A"&i).select
xlapp.activecell.formular1c1 =uidoc.fieldgettext("keyword"&(i-1))
xlapp.range("B"&i).select
xlapp.activecell.formular1c1 =uidoc.FieldGetText("count"&(i-1))
Next
xlapp.range("A2:B23").select
Call xlapp.selection.sort(xlapp.range("B2"),2)
xlapp.charts.add
xlapp.activechart.charttype=51 'xlcolumnclustered
xlapp.activechart.setsourcedata
xlapp.sheets("sheet1").range("A2:B9"),2
xlapp.activechart.seriescollection(1).name="=""notes chart"""
xlapp.activechart.location 2,"sheet1"'xllocationasobject
With xlapp.activechart
.astitle=True
.charttitle.characters.text=uidoc.FieldgetText("title")
.axes(1,1).hastitle=True 'xlcategory,xlprimary
.axes(1,1).axistitle.characters.text=uidoc.FieldGetText("x_axis_label")
.axes(2,1).hastitle=True 'xlvalue,xlprimary
.axes(2,1).axistitle.characters.text=uidoc.FieldGetText("y_axis_data")
.applydatalabels 2,True 'xldatalabelsshowvalue
.hasdatatable=False
End With
xlapp.activesheet.shapes("chart 1").scaleheight 1.5,0,0
xlapp.activesheet.shapes("chart 1").scalewidth 1.9,0,0
Exit Sub
errh:
buttonhide="yes"
Resume Next
End Sub
Sub Terminate
On Error Resume Next
xlapp.displayalerts=False
xlapp.quit 'use the quit method to close
Set xlapp=Nothing 'release the reference
End Sub |
|