Export A View To Xls File

This script export a notes view to a XLS file automatically !
Sub ExportXLS(Vue As String, Fichier As Variant)

'----------------------- Declarations ----------------------------------

Dim Session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim doc As NotesDocument

Dim nbcol As Integer
Dim i,k As Variant
Dim Handle As Variant
Dim Wbook, Wsheet As Variant
Dim column As NotesViewColumn


'-------------------------------------------------------------------------------

Set db=Session.CurrentDatabase
Set view=db.Getview(Vue)

Set Handle=CreateObject("Excel.Application")
Set Wbook=Handle.Workbooks.Add
Set WSheet=Wbook.Worksheets(1)

k=0
nbcol = Ubound(view.Columns)

' Affiche le nom des colonnes dans la premi?re ligne du fichier Excel
Do

Set column=view.Columns(k)
Wsheet.Cells(1, k+1).Value=column.Title
k=k+1

Loop Until k=nbcol+1

' Remplit les cellules du fichiers avec les diff?rentes valeurs qui se
trouvent dans la vue
i=2
Set doc=view.Getfirstdocument()

While Not (doc Is Nothing)
For k = 0 To nbcol
Wsheet.Cells(i,k+1).Value=doc.ColumnValues(k)
Next

Set doc = view.GetNextDocument(doc)
i = i + 1
Wend

' Mise en page
Wsheet.Rows(1).Font.Bold=True
Wsheet.Rows(1).Font.Size=12

For k=1 To nbcol+1
Wsheet.Columns(k).Autofit
Next

Wbook.SaveAs(Fichier)
Wbook.close
Handle.Quit

Set Worksheet=Nothing
Set Workbook=Nothing
Set Handle=Nothing

End Sub

This was first published in November 2000

Dig Deeper

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchWindowsServer

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchEnterpriseLinux

SearchDataCenter

SearchExchange

SearchContentManagement

Close