Das Notes Forum

Domino 9 und frühere Versionen => Entwicklung => Thema gestartet von: robertpp am 24.04.03 - 18:08:36

Titel: Export zu Excel von eknori etwas anders
Beitrag von: robertpp am 24.04.03 - 18:08:36
Ich hab mir eknoris script als vorlage genommen nur möchte ich nicht die ganzen doc aus der ansicht nehmen sonder nur die docs aus der DocCollection.
Die DocCollection wird aber wo anders gefüllt. Das hab ich aber schon.
Wir nehmen also an dort sind doc drinnen.

   Dim s As New NotesSession
   Dim ws As New NotesUIWorkspace    
   Dim sourceview As NotesView
   Dim sourcedoc As NotesDocument
   Dim dataview As NotesView
   Dim dc As NotesDocumentCollection
   Dim datadoc As NotesDocument
   Dim uiview As NotesUIView
   Dim maxcols As Integer    
   Dim cols As Integer, intLastRow As Integer
   Dim rows As Integer
   Dim getfield As Variant
   
   Set uiview=ws.CurrentView
   Set dataview = uiview.view
   Dim xlApp As Variant
   Dim xlsheet As Variant
   
   Msgbox Cstr(dc.Count) + " Dokumente..."   
   Set xlApp = CreateObject("Excel.Application")
   xlApp.Visible = True
   xlApp.Workbooks.Add
   xlApp.ReferenceStyle = 3
   Set xlsheet = xlApp.Workbooks(1).Worksheets(1)
   xlsheet.Name = uiview.ViewName
   cols=1
   Forall X In dataview.Columns
      xlsheet.Cells(1,cols).Value =X.title
      cols=cols+1
   End Forall
   
   
   ich hab das hier auch schon umgestellt
   Set datadoc = dc.GetFirstDocument
   cols=1
   rows=2
   
   maxcols= dataview.ColumnCount
   While Not (datadoc Is Nothing)
      For cols=0 To maxcols-1
         nur das problem tritt hier auf. Wie komm ich jetzt nur auf die ColumnValues wenn das doc "datadoc" nicht über die ansicht gesetzt wurde? Geht das überhaupt oder muss ich jetzt meine Felder  einzeln angeben die im Excel haben möchte?
         getfield = Cstr(datadoc.ColumnValues( cols ))  
         xlsheet.Cells(rows,cols+1).Value = getfield  
      Next
      rows=rows+1
      cols=0
      Set datadoc = dc.GetNextDocument(datadoc)  
      
   Wend
   
   
   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 = 1' Spaltenkopf Farbe
      .Pattern = 0  
      .PatternColorIndex =0
   End With
   xlApp.StatusBar = "Titel formatiert"
   xlApp.Rows("1:1").Select 'Zeile 1 bis 1 ist  
   xlApp.Selection.Font.Bold = True ' Fett
   xlApp.Range(xlsheet.Cells(1,1), xlsheet.Cells(rows,maxcols)).Select
   xlApp.Selection.Font.Name = "Arial" 'Schrift Art
   xlApp.Selection.Font.Size = 10'Schriftgröße der Excel Tab
   xlApp.Selection.Columns.AutoFit
   xlApp.Rows("1:1").Select
   xlApp.Selection.Rows.AutoFit
   With xlApp.Worksheets(1)
      .PageSetup.Orientation = 2
      .PageSetup.centerheader = "inventory list" ' Tabellen Überschrift
      .Pagesetup.RightFooter = "Seite: &P" & Chr$(13) & "Date: &D"
      
      .Pagesetup.CenterFooter = ""
   End With
   xlApp.Columns("B:B").Select
   xlApp.Selection.Delete
   xlApp.Columns("C:C").Select
   xlApp.Selection.Delete   
   xlApp.ReferenceStyle = 1
   xlApp.Range("A1").Select
   xlApp.StatusBar = "Fertig!"

Titel: Re:Export zu Excel von eknori etwas anders
Beitrag von: ata am 24.04.03 - 20:23:58
... du hast es richtig erfasst, eine view steht dir nicht zur Verfügung. von daher must die Felder deiner Docs auslesen und nach Excel weiterschieben...

ata