I have an application deployed in the development server (notes client). The application composed a function to export the data in the local machine of the user along with the graph generation. My problem is, when the data are exported, the rendering of graph is incorrect (in the server), but when I run it in my local machine the graph rendering is fine. I used MS 2007 in my local machine but in the development server there is NO MS Office installed.Is there any way to do this? Here is the code below.
Dim s As New notessession
Dim db As notesdatabase
Set db= s.currentdatabase
Dim uiw As New NotesUIWorkspace
Dim otherdoc As NotesDocument
Dim otherview As NotesView
Dim othercol As NotesDocumentCollection
Dim ViewNav As NotesViewNavigator
Dim entry As notesViewEntry
Dim tempdoc As notesdocument
Dim uiv As notesuiview
Set uiv = uiw.currentview
Dim VName As String
VName = uiv.ViewName
'if it is R4 then viewalias doesn't work so use
'environment variable stashed in the post open event
If Instr(s.Notesversion, "Release 4") Then
currentviewname = s.getenvironmentstring("Tracking")
If currentviewname="" Then
Msgbox "View not exist."
End
End If
Call s.setenvironmentvar("Tracking","")
Elseif uiv.viewalias <> "" Then 'use alias if it isn't blank
currentviewname = uiv.viewalias
Else ' use name
currentviewname = uiv.viewname
End If
'Get the view
Set otherview = db.GetView(currentviewname)
If otherview Is Nothing Then
Messagebox "Could not open the view. """ & currentviewname & """"
Exit Sub
End If
'Check if it is for all documents or only selected
Set othercol = db.unprocesseddocuments
If othercol.count >1 Then 'if more than one doc selected then confirm
resp = Messagebox("Do you want to export only the " & _
"selected " & othercol.count & " documents?", 36, "Selected only?" )
If resp=6 Then
Else
Exit Sub
End If
Else
Messagebox "Exporting all rows. (To export only selected " & _
"rows tick those required in the left margin first.)"
End If '6= yes
Dim object As NotesEmbeddedObject
Dim xlApp As Variant
Dim oWorkbook As Variant
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = True 'set to visible, this can be moved to the end if you wish
Set oworkbook = xlApp.Workbooks 'handle to Workbook
oworkbook.Add
'Stick out the column headers
hcolmn=1
Forall c In otherview.Columns
xlApp.cells(1,hcolmn) = c.title
hcolmn=hcolmn+1
End Forall
row=2
Dim vc As NotesViewEntryCollection
Dim seldoc As notesdocument
Dim view As notesview
Set view = db.GetView(VName)
Set vc = view.AllEntries
If resp=6 Then
Set seldoc = othercol.GetFirstDocument
While Not seldoc Is Nothing
Set entry = vc.GetEntry(selDoc)
Print "Entry " entry.noteID " from document " selDoc.noteID '<--- new line
'Msgbox row
For colmn = 0 To Ubound(entry.ColumnValues)
col% = col% + 1
xlApp.cells(row,colmn+1) = entry.columnvalues(colmn)
开发者_如何转开发 Next
row=row+1
Set seldoc = othercol.GetNextDocument(seldoc)
Wend
Else ' all documents
Set otherdoc = otherview.GetFirstDocument
While Not otherdoc Is Nothing
For colmn = 0 To Ubound(otherview.Columns)
xlApp.cells(row,colmn+1) = otherdoc.columnvalues(colmn)
Next
row=row+1
Set otherdoc = otherview.GetNextDocument(otherdoc)
Wend
End If
'this highlights the headings
xlApp.application.Rows("1:1").Select
With xlApp.application.Selection.Font
.bold = True
.ColorIndex = 48
.Name = "Arial"
.Size = 10
End With
'this freezes the panes
xlApp.application.Rows("2:2").Select
xlApp.application.ActiveWindow.FreezePanes = True
xlChartType = 51
xlapp.ActiveWorkbook.Charts.Add
With xlapp.ActiveWorkbook.ActiveChart
.Name = "Chart"
.HasTitle = True
.ChartTitle.Text = "Total Submissions Received per Month"
.Axes("1").HasTitle = True 'xlCategory = x axis
.Axes("1").AxisTitle.Text = "Month"
.Axes("1").AxisTitle.AutoScaleFont = True
.Axes("1").AxisTitle.Font.Size = 8
.Axes("2").HasTitle = True 'xlValue = y axis
.Axes("2").AxisTitle.Text = "No. of Submission"
.Axes("2").AxisTitle.AutoScaleFont = True
.Axes("2").AxisTitle.Font.Size = 8
.ChartType = xlChartType
.PlotArea.Interior.ColorIndex = "0"
.PlotBy = "1" '2 = Column Plot
.SetSourceData xlApp.Worksheets("Sheet1").Range("A1","N6")
End With
The fact that you instantiate new NotesUIWorkspace
means that the agent does not run on the server. So you should probably ask about the version of Excel on the computers of other users, who run the code. Note that the agent would only run on the server if it is scheduled or if you make it run on the server using notesAgent.RunOnServer( [ noteID$ ] )
.
I changed this line and it works fine even there is no excel installed on the server. change SetSourceData xlApp.Worksheets("Sheet1").Range("A1","N6") to SetSourceData xlApp.Worksheets("Sheet1").Range("A1","N" & row-1)
精彩评论