Domino 9 und frühere Versionen > ND6: Entwicklung

Export von Notes to Excel

<< < (2/2)

Christoph.1982:
Zitat
For n = 0 To Ubound(vE.ColumnValues)
Hier wird hochgezählt.

Aber da wird doch nur die Columns hochgezaehlt...und wo werden die rows hochgezaehlt?

Christoph.1982:
Da haett ich noch ne Frage, dann versteh ich das auch besser mit den rows...in dem view sind 5000 rows und wenn ich da jetzt nur die ersten 100 in excel haben moechte was muesste ich dann oben in dem Programm Code aendern?

Viele Gruesse Chris

m3:
Die Abbruchbedinung für die While-Schleife, in der er die Zeilen durchgeht anpassen.

Kann es sein, dass Du noch nicht wirklich viel Coding-Erfahrung hast? Was sagt Dein Mentor/Ausbildner/Chef? Kannst Du den nicht fragen?

Christoph.1982:
Hallo, hat sich erledigt...habs hinbekommen  :)
ne, also von programmieren hab ich nicht soviel Ahnung, da ich Maschinenbau Student bin...aber ich mache gerade ein Praktika und da muss ich mit LotusNotes arbeiten...

Viele Gruesse Chris

Hier der fuktionierende Code:

Sub Click(Source As Button)
   Dim s As New NotesSession
   Dim View As NotesView
   Dim EC As NotesViewEntryCollection
   Dim vE As NotesViewEntry
   Dim n As Long
   Dim Row As Long
   Dim xlApp As Variant
   Dim xlWB As Variant
   Dim xlSheet As Variant
   Dim column As NotesViewColumn
   Dim i As Integer
   
   On Error Goto Error_Export
   
   Set View = s.CurrentDatabase.getView("Phone Log / ServiceFollowUp")
   If Not(View Is Nothing) Then
      Set xlApp = createobject("Excel.Application")
      xlApp.StatusBar = "Create WorkSheet. Please wait."
      xlApp.DisplayAlerts = False
      xlApp.Visible = True
      Set xlWB = xlApp.WorkBooks.Add
      Set xlSheet = xlWB.Sheets(1)
      
      xlSheet.Name = "MainData"
      
      ' write the columnnames
      Row = 1
      For i = 0 To view.ColumnCount -1
         Set column = view.Columns(i)
         xlSheet.Cells(Row, i +1) = column.ItemName         
      Next
      
      ' format the columnnames (grey and bold)
      xlSheet.Range("A1:AW1").Interior.ColorIndex = 15
      xlSheet.Range("A1:AW1").Font.Bold = True
      
      ' write the rows
      Set EC = View.AllEntries      
      Set vE =EC.getFirstEntry
      Row=0
      While (Row <=100)         
         If vE.IsDocument Then
            Row = Row + 1
            ' not the last row
            For n = 0 To Ubound(vE.ColumnValues)
               xlSheet.Cells(Row, n + 1) = vE.ColumnValues(n)     ' to prevent excel errors         
            Next
            xlApp.StatusBar = "Importing Notes Data"
         End If      
         Set vE = EC.getNextEntry(vE)
      Wend
   End If
   
   xlApp.Cells.Select
   xlApp.Selection.Columns.AutoFit
   xlApp.Selection.Rows.AutoFit
   xlApp.Range("A1").Select
   
   Call xlWB.SaveAs("C:\PhoneLogServiceFollowUp.xls")
   Call xlWB.Close
   Call xlApp.Quit
   
   Messagebox "Export successful to C:\PhoneLogServiceFollowUp.xls!", 64, "Information"
   
Error_Export:   
   If (Err <> 0) Then
      Messagebox Error$, 48, "An error has occurred..."
   End If
   Exit Sub   
   
End Sub

Navigation

[0] Themen-Index

[*] Vorherige Sete

Zur normalen Ansicht wechseln