'WebPrintMailSpaceReport: Option Public Option Explicit Sub Initialize Dim session As New NotesSession Dim db As NotesDatabase Dim doc As NotesDocument Dim dc As NotesDocumentCollection Dim view As NotesView Dim cview As NotesView Dim row As Integer ' an example of how the agent should be called ' http://ServerName/YourDatabase.nsf/WebAgentName?OpenAgent&ViewNameToExport Dim ViewName As String Set db = session.CurrentDatabase Set db=session.currentdatabase Set doc = session.DocumentContext Dim path As String Dim pos As Integer Path= doc.Query_String_Decoded(0) pos = Instr(path, "&") viewname=Mid(path, pos+1) ' Print "
view=" & viewName & "
" ' debug only 'ViewName= "VewNametoExport" ' if you waht to hard code the view name Set view=db.GetView(ViewName) Call WriteViewasExcel (View) End Sub Sub WriteViewasExcel (view As Notesview) Dim fileNum As Integer Dim entry As NotesViewEntry Dim vc As NotesViewEntryCollection Dim rowstring As String Dim cns As String Print |Content-Type:application/vnd.ms-excel| Print || ' use the view column titles as the CSV headers Forall c In view.Columns ' Print c.title ' if your view title contants html this is good Print || ' if your view title does not contain html End Forall ' Print cns Print || ' now get and print the values for each row and column Set vc = view.AllEntries Set entry = vc.GetFirstEntry() While Not entry Is Nothing rowstring = "" Print || Forall colval In entry.ColumnValues Print || End Forall Print || ' Print #fileNum%, rowstring Set entry = vc.GetNextEntry(entry) Wend Print |
| & c.title & |
| & colval & |
| End Sub