Das Notes Forum

Lotus Notes / Domino Sonstiges => Tipps und Tricks => Thema gestartet von: Master Of Desaster am 05.12.02 - 07:12:27

Titel: Formatierter Export zu Excel per LotusScript
Beitrag von: Master Of Desaster am 05.12.02 - 07:12:27
Hallo zusammen,

ich hab hier ein wirklich nettes Script um Ansichten komplett und formatiert nach Excel zu exportieren - ist leider nicht von mir, ich poste es trotzdem, weil es wirklich gut ist. Danke an den unbekannten Programmierer!

Das ganze kopieren und als Aktion in die Ansicht einbinden - fertig...

Sub Click(Source As Button)
   Dim Session As New NotesSession
   Dim db As NotesDatabase
   Dim sourceview As NotesView
   Dim sourcedoc As NotesDocument
   Dim dataview As NotesView
   Dim datadoc As NotesDocument
   Dim maxcols As Integer
   Dim WS As New Notesuiworkspace
   Dim UiView As notesuiview
   Dim cols As Integer
   Dim rows As Integer
   Dim getfield As Variant
   
   Set db = session.CurrentDatabase
   Set UiView=WS.currentview
   Set dataview = uiview.view
   Dim xlApp As Variant
   Dim xlsheet As Variant
   
   Set xlApp = CreateObject("Excel.Application")
   xlApp.StatusBar = "Import vorbereiten..."
   xlApp.Visible = True
   xlApp.Workbooks.Add
   xlApp.ReferenceStyle = 2
   Set xlsheet = xlApp.Workbooks(1).Worksheets(1)
   xlsheet.Name = uiview.viewname
   xlApp.StatusBar = "Überschriften erstellen..."
   cols=1
   Forall X In dataview.Columns
      xlsheet.Cells(1,cols).Value =X.title
      cols=cols+1
   End Forall
   
   xlApp.StatusBar = "Überschriften erstellen...fertig!"
   xlApp.StatusBar = "Import vorbereiten..."
   xlApp.StatusBar = "Daten importieren..."
   Set datadoc = dataview.getfirstdocument
   cols=1
   rows=2
   maxcols= dataview.columncount
   While Not (datadoc Is Nothing)
      For cols=0 To maxcols-1
         getfield = Cstr(datadoc.ColumnValues( cols ))
         xlsheet.Cells(rows,cols+1).Value = getfield
      Next
      rows=rows+1
      cols=0
      Set datadoc = dataview.getnextdocument(datadoc)
   Wend
   xlApp.StatusBar = "Import beendet! ... Formatieren starten"
   
   xlApp.Rows("1:1").Select
   xlApp.Selection.Font.Bold = True
   xlApp.Range(xlsheet.Cells(1,1), xlsheet.Cells(1,maxcols)).Select
   With xlApp.Selection.Interior
      .ColorIndex = 15
      .Pattern = 17 'xlGray16
      .PatternColorIndex =6
   End With
   xlApp.StatusBar = "Titel formatiert"
   xlApp.Rows("1:1").Select
   xlApp.Selection.Font.Bold = True
   xlApp.Range(xlsheet.Cells(1,1), xlsheet.Cells(rows,maxcols)).Select
   xlApp.Selection.Font.Name = "Arial"
   xlApp.Selection.Font.Size = 9
   xlApp.Selection.Columns.AutoFit
   With xlApp.Worksheets(1)
      .PageSetup.Orientation = 2
      .PageSetup.centerheader = "Report - Confidential"
      .Pagesetup.RightFooter = "Page &P" & Chr$(13) & "Date: &D"
      .Pagesetup.CenterFooter = ""
   End With
   xlApp.ReferenceStyle = 1
   xlApp.Range("A1").Select
   xlApp.StatusBar = "Fertig!"
End Sub
Titel: Re:Formatierter Export zu Excel per LotusScript
Beitrag von: Don Pasquale am 05.12.02 - 14:32:26
Hi M.O.D.,

escht nischt schlescht für ein Diesel :-)

Aber vielleicht erinnerst Du Dich noch wo Du es herhast, falls man noch fragen hat.

Vielleicht könnte noch irgendein Admin diesen Thread zu R5- Entwicklung rübersetzen, da passt es besser meine ich.

Ciao
Don Pasquale

ps: frisch dabei und schon konstruktiv, respekt !
Titel: Re:Formatierter Export zu Excel per LotusScript
Beitrag von: Master Of Desaster am 06.12.02 - 08:14:59
Hi Don Pasquale,

dieses Script hab ich bei JNotes ausgegraben - aber ich glaube auch da ist der Programmierer längst verschollen  ;)

Danke für die Blumen...
Aber dieses Forum ist wirklich klasse und hat mir gestern schon weitergeholfen - da tu ich dann auch was ich kann (ist wenig genug).

Aber auch ich lern es noch ... irgendwann  ;D

Saludos,
MOD