Fabio Di Paola

Un pezzetto di codice (LotusScript)

21 Settembre 2010 Notes Sviluppo 0

Magari a qualcuno puo’ servire : e’ un pezzetto di LotusScript che lanciato da una view esporta tutti i doc. della view stessa in Excel, e’ generico e quindi non c’e’ bisogno di parametrizzarlo per view diverse.
Non l’ho ottimizzato, potrebbero esserci ancora delle Dim non piu’ necessarie, comunque funziona.

Sub Initialize
Dim x,y As Integer
Dim conta, salto,lunga As Integer
Dim strLen As Integer
Dim ses As NotesUIworkspace
Dim vw As NotesUIView
Dim view As NotesView
Dim doc As NotesDocument
Dim it As Variant
Dim viewcollec As notesviewentrycollection
Dim viewentry As notesviewentry
Dim strDesc As String
Dim strTrack As String
Dim session As New NotesSession
Dim db As NotesDatabase
Set db = session.CurrentDatabase
Set ses = New NotesUIWorkspace
Set vw = ses.currentview
Set View = vw.View

‘Set up the Excel application
Dim xlApp As Variant
Dim xlSheet As Variant

Set xlApp = CreateObject(“Excel.application”)
xlApp.Workbooks.Add

Set xlSheet = xlApp.Workbooks(1).Worksheets(1)
xlApp.Visible = True

‘- Set the print to landscape
‘Values you can use:
‘1 = Portrait
‘2 = Landscape
xlSheet.PageSetup.Orientation = 2

‘Titoli delle colonne
x=0
Forall c In view.Columns
x=x+1
xlSheet.Columns(x).Columnwidth = c.Width
xlSheet.Columns(x).VerticalAlignment = 1 ‘The vertical alignment defaults to bottom in excel, and this makes the data look a LOT cleaner
xlSheet.Cells(1, x).Value = c.Title
End Forall

Set viewcollec=view.allentries
Set ViewEntry = viewcollec.GetFirstEntry( )

x=1
Do While Not viewentry Is Nothing
x=x+1
y=0
Forall v In viewentry.ColumnValues
y=y+1
xlSheet.Cells(x, y).Value = v
End Forall
Set ViewEntry = viewcollec.GetNextEntry( viewentry )
Loop

Msgbox “Il foglio Excel e’ pronto, ricordati di salvarlo!”, 64, “Excel Export”

End Sub

Buon codice !
Lotus Notes Domino