Das Notes Forum

Domino 9 und frühere Versionen => ND6: Entwicklung => Thema gestartet von: Viktor am 06.01.05 - 11:56:04

Titel: ausgewählte docs ins excel exportieren????
Beitrag von: Viktor am 06.01.05 - 11:56:04
hallo forum

mit dieser action (siehe unten) werden alle dokumente aus einer ansicht direkt ins excel exportiert, so weit so gut.

meine frage: kann man aber nur ausgewählte dokumente aus einer ansicht ebenfalls so exportieren, wenn ja wie?

besten dank im voraus

gruss

viktor

:_________________________________________________


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: ausgewählte docs ins excel exportieren????
Beitrag von: klaussal am 06.01.05 - 12:02:43
Suche mal in der Hilfe nach dem Stichwort "Unprocessed documents".

klaus
Titel: Re: ausgewählte docs ins excel exportieren????
Beitrag von: Viktor am 06.01.05 - 12:24:13
danke klaus aber ich komme leider nicht weiter :-( :-[
Titel: Re: ausgewählte docs ins excel exportieren????
Beitrag von: Axel am 06.01.05 - 12:30:05
Hi,

so geht's:

Dim Session As New NotesSession
Dim db As NotesDatabase
Dim collection As NotesDocumentCollection
Dim doc As NotesDocument

Set db = session.CurrentDatabase
Set collection = db.UnprocessedDocuments

Set doc = collection.GetFirstDocument
While Not (doc Is Nothing)

'hier findet die Verarbeitung der einzelnen Doks statt

  Set doc = collection.GetNextDocument(doc)
Wend


Axel
Titel: Re: ausgewählte docs ins excel exportieren????
Beitrag von: Viktor am 06.01.05 - 12:38:33
hallo axel

und wie kann ich das in meinem script inplementieren?
SORRY, Ich kenn mich ein wenig aus, aber nicht so gut, dass ich schon alle Funktionen etc. kennen würde. Bin daher für jeden Tipp sehr dankbar.

Vielen Dank und Gruss

Viktor
Titel: Re: ausgewählte docs ins excel exportieren????
Beitrag von: Axel am 06.01.05 - 18:11:34
Hi,

so müsste das gehen. Die Anpassungen sind fett gedruckt. Ich hoffe ich habe nichts übersehen.

Sub Click(Source As Button)
   Dim Session As New NotesSession
   Dim db As NotesDatabase
   Dim collection As NotesDocumentCollection
   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 collection = db.UnprocessedDocuments
   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 = collcetion.getfirstdocument
   'cols=1

   rows=2
   maxcols= dataview.columncount
   While Not (datadoc Is Nothing)

      xlsheet.Cells(rows,1).Value = datadoc.NamedesFeldes1(0)
      xlsheet.Cells(rows,2).Value = datadoc.NamedesFeldes2(0)
      'Hier können weitere Felder exportiert werden
      'Feldnamen müssen angepasst werden

      Set datadoc = collection.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

Bei dieser Art und Weise kann nicht über den Spaltenindex auf die Feldinhalte zugegriffen werden, sondern man muss über den Feldnamen den Inhalt auslesen. Die Feldnamen musst du an deine Gegebenheiten anpassen.


Axel
Titel: Re: ausgewählte docs ins excel exportieren????
Beitrag von: koehlerbv am 06.01.05 - 18:35:50
Warum kommt mir der verwendete Code nur so bekannt vor ?  ;D

Ich kann allerdings nur den dringenden Rat geben, keinen Code zu verwenden, den man nicht verstanden hat. Das ist unprofessionell und ein Spiel mit dem Feuer. Das Glück, dass jemand dann den Samariter spielt und einem die Arbeit abnimmt, ist ja nun doch aussergewöhnlich.

Bernhard
Titel: copy selected as table
Beitrag von: dh-paule am 06.01.05 - 19:39:19
vielleicht bin ich mal wieder zu blauäugig, aber was ist mit der LN6 Funktion "copy selected as table" Das kann der user doch auch nutzen...

aber vermutlich hab ich's mir grad nur zu einfach gemacht  ;)
Titel: Re: ausgewählte docs ins excel exportieren????
Beitrag von: MartinG am 06.01.05 - 22:48:05
Zitat
"copy selected as table"   

Sehr schöne Funktion - wäre halt noch schön wenn man das per Script oder Formel in eine Aktion packen könnte, aber da hat sich bei IBM vermutlich keiner Gedanken gemacht.

Gruss
Martin
Titel: Re: ausgewählte docs ins excel exportieren????
Beitrag von: Viktor am 07.01.05 - 08:55:53
herzlichen dank an axel und an alle "samariter"  :-X
Titel: Re: ausgewählte docs ins excel exportieren????
Beitrag von: stussy am 16.06.05 - 11:08:22
Hallo,

ich habe ebenfalls das Script für den FileExport verwendet. Es funktioniert echt gut. :-*

Nun habe ich aber doch ein Problem das ich mal kurz beschreiben will.
Die Ansicht, die ich exportieren will, enthält eine Spalte die Mehrfachwerte beinhaltet (getrennt durch "komma").
Sobald ich das Script ausführe, zeigt es mir einen "Type missmatch" an.
Wie kann ich die Mehrfachwerte in einem String holen und ins Excel exportieren?

NotesProfis..ihr seit meine letzte Hoffnung  :)
Titel: Re: ausgewählte docs ins excel exportieren????
Beitrag von: ctillmanns am 16.06.05 - 11:22:06
join dürfte das sein, was Du suchst.
Titel: Re: ausgewählte docs ins excel exportieren????
Beitrag von: stussy am 16.06.05 - 16:30:47
DANKE!!! Das war es. Jetzt funzzt alles.

Titel: Re: copy selected as table
Beitrag von: ctillmanns am 17.06.05 - 09:57:09
Moin
Zu:
Zitat
"copy selected as table"
Das kann man mit ND 6 im Backend wirklich schön mit LS lösen. Die Tabelle kann man da auch noch besser formatieren. Sofern man das in ein Richtextfeld einfügen will. Vielleicht hat sich schon jemand gefunden, der das als Tool programmiert hat.
Wenn es allerdings nur darum geht, dass man sich einmal Klicken spart, dann kann ich wieder mal mein Lieblingsthema anschneiden. Programmiere man halt die Tastenkombinationen. Dazu habe ich dann wohl in letzter Zeit wirklich genug gesagt.
Cheerio
Tilsche
PS: Langsam habe ich das Gefühl, damit könnte ich Geld verdienen.