Domino 9 und frühere Versionen > ND6: Entwicklung
Mail mit mehrere dynamischen Tabellen
sja:
Hallo,
wenn jemand Interesse hat, ist hier meine Lösung, wie kommt man auf erste TableCell in letzter Tabelle (s. Kommentare in dem Code mit dem Anfang: '!!!). Leider kann ich nicht das wörtlich erklären.
Vielen Dank noch mal @umi für eine Idee, die Anzahl tabellen in einer globalen Variablen zu speichern!
Sub Initialize
…
GrVB = Evaluate({@Name([CN];@DbLookup( "":"NoCache"; "} + srv + {" : "names.nsf" ; "($VIMGroups)" ; "VB" ; 3 ))})
tabelle = 0 '!!! Globale Variable
Forall tmpGrVB In GrVB
key = tmpGrVB
Set vec = view.GetAllEntriesByKey(key, True)
tmpWoche = Woche
If Not(vec.Count = 0) Then
tabelle = tabelle + 1 '!!! Für jede neue Tabelle
Message1 = "Auflistung der Termine für vorherige Kalenderwoche " & Woche_1 &_
" und aktuelle Kalenderwoche " & Woche & " für " & key & Chr(13) & Chr(13)
Message2 = "-> " & key & " / " & Jahr & " / KW" & tmpWoche
Call body.AppendText( Message1)
Call body.AppendText( Message2)
'If vec.Count = 0 Then Exit Function
totalRows = vec.Count + 1
Call setRichTextStyles
If Not createReport(tabelle) Then Error ERR_EXITNOMSG, MSG_EXITNOMSG
Call populateTable(tabelle)
End If
End Forall
MailDoc.Send(False)
…
End Sub
Function createReport(tabelle) As Integer
On Error Goto errHandler
createReport = True
Dim color As NotesColorObject
Dim columnHeader(9) As String
Dim tableColStyles(1 To 9) As NotesRichTextParagraphStyle
columnHeader(1) = "Link" ' Initialize column header values
columnHeader(2) = "Datum"
columnHeader(3) = "Von - Bis"
columnHeader(4) = "PYM-Kundenname"
columnHeader(5) = "Kontakt Typ"
columnHeader(6) = "PYM-Projektname"
columnHeader(7) = "cIT Produkt"
columnHeader(8) = "Zielsetzung"
columnHeader(9) = "Ergebnis"
' Populate the array of NotesRichTextParagraphStyle - one array element (one NotesRichTextParagraphStyle) for each column.
For i = 1 To COLUMN_COUNT Step 1
Set tableColStyles(i) = session.CreateRichTextParagraphStyle ' Create the rt paragraph style for this column
tableColStyles(i).FirstLineLeftMargin = 0 ' Set left margin for the first line of each cell in column
tableColStyles(i).LeftMargin = 0 ' Set left margin for all but the first line of each cell in column
Select Case i
Case 1
tableColStyles(i).RightMargin = RULER_ONE_CENTIMETER * 0.7
tableColStyles(i).Alignment = ALIGN_CENTER
Case 2
'tableColStyles(i).LeftMargin = RULER_ONE_CENTIMETER * 0.1
tableColStyles(i).RightMargin = RULER_ONE_CENTIMETER * 2
Case 3
tableColStyles(i).RightMargin = RULER_ONE_CENTIMETER * 3
Case 4
tableColStyles(i).RightMargin = RULER_ONE_CENTIMETER * 4
Case 5
tableColStyles(i).RightMargin = RULER_ONE_CENTIMETER * 2
Case 6
tableColStyles(i).RightMargin = RULER_ONE_CENTIMETER * 2
tableColStyles(i).Alignment = ALIGN_CENTER
Case 7
tableColStyles(i).RightMargin = RULER_ONE_CENTIMETER * 2
tableColStyles(i).Alignment = ALIGN_CENTER
Case 8
tableColStyles(i).RightMargin = RULER_ONE_CENTIMETER * 2
tableColStyles(i).Alignment = ALIGN_CENTER
Case 9
tableColStyles(i).RightMargin = RULER_ONE_CENTIMETER * 2
tableColStyles(i).Alignment = ALIGN_CENTER
End Select
Next
Call body.AppendTable( totalRows, COLUMN_COUNT,,, tableColStyles)
Set rtNav = body.CreateNavigator
If Not (tabelle >1) Then '!!! Wird erste Tabelle erstellt
Call rtNav.GetFirstElement(RTELEM_TYPE_TABLE)
Set rtTable= rtNav.GetElement
rtTable.Style = TABLESTYLE_TOP
Set color = session.CreateColorObject ' Create color object for use in setting cell colors
color.NotesColor = COLOR_LIGHT_GRAY
Call rtTable.SetColor( color ) ' Set the top row color to light gray background
color.NotesColor = COLOR_WHITE
Call rtTable.SetAlternateColor( color ) ' Set all rows after the top row to white background
Call rtNav.FindFirstElement( RTELEM_TYPE_TABLECELL ) ' Move to the first cell - row 1, col 1
Call body.AppendStyle( rtHelv8_Black_Bold ) ' Set the font to Helvetica, 8-point, bold black
For col = 1 To COLUMN_COUNT Step 1
Call body.BeginInsert( rtNav )
Call body.AppendText( columnHeader(col) ) ' Write the text for this column's header
Call body.EndInsert ' Move insertion point to the end of this cell
Call rtNav.FindNextElement( RTELEM_TYPE_TABLECELL ) ' Move to the next cell
Next
Else '!!! wird immer nächste Tabelle erstellt
'!!! Findet letzte Tablecell-Element im Navigator
Call rtNav.FindLastElement(RTELEM_TYPE_TABLECELL)
Call rtNav.GetLastElement(RTELEM_TYPE_TABLE) '!!! Geht zu letzter Tabelle
Set rtTable= rtNav.GetElement
'!!! Findet nächste Tablecell-Element im Navigator, d. h. erste Tablecell-Element in der letzte Tabelle
Call rtNav.FindNextElement( RTELEM_TYPE_TABLECELL )
rtTable.Style = TABLESTYLE_TOP
Set color = session.CreateColorObject ' Create color object for use in setting cell colors
color.NotesColor = COLOR_LIGHT_GRAY
Call rtTable.SetColor( color ) ' Set the top row color to light gray background
color.NotesColor = COLOR_WHITE
Call rtTable.SetAlternateColor( color ) ' Set all rows after the top row to white background
Call body.AppendStyle( rtHelv8_Black_Bold ) ' Set the font to Helvetica, 8-point, bold black
For col = 1 To COLUMN_COUNT Step 1
Call body.BeginInsert( rtNav )
Call body.AppendText( columnHeader(col) ) ' Write the text for this column's header
Call body.EndInsert ' Move insertion point to the end of this cell
Call rtNav.FindNextElement( RTELEM_TYPE_TABLECELL ) ' Move to the next cell
Next
End If
…
End Function
Navigation
[0] Themen-Index
[*] Vorherige Sete
Zur normalen Ansicht wechseln