Friday, December 30, 2011

Export all view data to Symphony SpreadSheet(.ods) from Web

Create a button and call the following agent in onclick() of that button.

Note : For better output you have to map all required fields in the view.

Sub Initialize

On Error GoTo errorHandler

Dim session As New NotesSession

Dim db As NotesDatabase

Dim doc As NotesDocument

Dim stuDetailsView As NotesView

Dim viewEntryCollection As NotesViewEntryCollection

Dim viewEntry As NotesViewEntry

Dim fileName As String

Dim i As Integer

Dim j As Integer

Dim cnam As Variant

Set db = session.CurrentDatabase

Set stuDetailsView = db.GetView(”vwStudent”)

‘Assign ‘vwStudent’ view as NotesView

Set viewEntryCollection = stuDetailsView.AllEntries

‘ViewEntryCollection contains the handle of all documents in the view

Set viewEntry = viewEntryCollection.GetFirstEntry

‘View Entry have the handle of first document from the ViewEntryCollection

fileName = “Web All Documents.ods”

‘File name of the Symphony spreadsheet with ‘ods’ extension

Print |Content-Type:application/Lotus Symphony Spreadsheet in Lotus Notes.exe|

Print |Content-Disposition: Attachment; fileName=”|+fileName+|”|

‘To display a prompt to user to save or open

Print “

‘Writing into the spreadsheet and creating/opening a table

Print “

‘Writes the Column header in the first row

For j=1 To stuDetailsView.EntryCount

‘Loop runs for all documents in the view and exits

Print “

For i=0 To stuDetailsView.ColumnCount-1

‘Loop runs for all columns in the each documents in the view

Print “

‘Writes all column values in the spreadsheet corresponding to the view

Next i

Set viewEntry=viewEntryCollection.GetNextEntry(viewEntry)

‘ Getting the next entry from the collection

Print “

Next j

Print “

Student NameStudent RegNoDate of BirthDepartmentBatchCollege Name
” & viewEntry.ColumnValues(i) & “
‘Closes the table

Exit Sub


Print “Error :” & Error() & “Line No :” & Erl()

‘ Prints the error and the line number where the error occurs

Exit Sub

End Sub

No comments:

Post a Comment