服务器中的图形渲染不正确
我在开发服务器(Notes 客户端)中部署了一个应用程序。该应用程序编写了一个函数来导出用户本地计算机中的数据以及图形生成。我的问题是,当导出数据时,图形的渲染不正确(在服务器中),但是当我在本地计算机中运行它时,图形渲染很好。 我在本地计算机上使用 MS 2007,但在开发服务器中没有安装 MS Office。有什么办法可以做到这一点吗?这是下面的代码。
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
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
事实上,您实例化新的
NotesUIWorkspace
意味着该代理不会在服务器上运行。因此,您可能应该询问运行该代码的其他用户计算机上的 Excel 版本。请注意,只有在已计划的情况下或使用notesAgent.RunOnServer( [ noteID$ ] ) 使其在服务器上运行时,代理才会在服务器上运行。
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 usingnotesAgent.RunOnServer( [ noteID$ ] )
.我更改了这一行,即使服务器上没有安装 Excel,它也可以正常工作。
将 SetSourceData xlApp.Worksheets("Sheet1").Range("A1","N6") 更改为 SetSourceData xlApp.Worksheets("Sheet1").Range("A1","N" & row-1)
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)