Domino 9 und frühere Versionen > ND6: Entwicklung
Mail mit mehrere dynamischen Tabellen
umi:
Nicht ganz schwierig :-)
z.B. durch übergabe eines Parameters an createReport
oder Du könntest auch die Anzahl tabellen in einer globalen Variablen speichern.
--- Code: ---Function createReport(tabell as integer) 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) = " Kundenname"
columnHeader(5) = "Kontakt Typ"
columnHeader(6) = " Projektname"
columnHeader(7) = "Produkt"
columnHeader( = "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
Call rtNav.GetFirstElement(RTELEM_TYPE_TABLE)
if (tabelle > 1 ) then
for i=0 to tabelle-1
call rtnav.getNextElement(RTELEM_TYPE_TABLE)
next
end if
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
finally:
Exit Function
errHandler:
createReport = False
Dim strErrMsg As String
Select Case Err
Case Else
strErrMsg = "Error #" & Err & Chr$(10) & Error$ & Chr$(10) & "Line #" & Erl & | in sub/function: "| & Lsi_info(2) & |"|
Msgbox strErrMsg, 16, "Unexpected error"
End Select
Resume finally
End Function
--- Ende Code ---
sja:
Herzlichen Dank für Deine Hilfe, @umi!
Ich probiere das.
Gruesse
Sofia
sja:
hallo,
habe so gemacht:
If Not (tabelle >1) Then
Set rtNav = body.CreateNavigator
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
Call rtNav.GetLastElement(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 rtNav.FindNthElement( RTELEM_TYPE_TABLECELL , tabelle)
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
jetzt color für den Tabelle-Kopf ist für nächste Tabelle da, aber nicht mehr (s. Bild-Anhang)
???
für weitere Hilfe werde sehr dankbar!
:'(
umi:
Kleiner Tipp: überprüf mal die Funktion populateTabelle... Welche RTNAv verwendet diese Funktion den richtigen RTNAv?
sja:
ich weiss nicht, wie kann ich auf erste Element in der letzten Tabelle zeigen
die poplate sieht so aus:
Function populateTable() As Integer
On Error Goto errHandler
populateTable = True ' Function returns TRUE unless we hit an error
Call body.AppendStyle( rtHelvPlain8 ) ' Set font to Helvetica, 8 point, black
If Not(vec.Count = 0) Then
Set ve = vec.GetFirstEntry()
Do Until ve Is Nothing
Set doc= ve.Document
For col = 1 To COLUMN_COUNT Step 1
Call body.BeginInsert( rtNav )
Select Case col ' Populate the detail cells of the table
Case 1
Call body.AppendDocLink( doc, doc.KundenProjektTitel(0))
Case 2
Call body.AppendText( doc.StartDate(0) )
Case 3
Call body.AppendText( doc.TimeRange(0))
Case 4
Call body.AppendText( doc.KundenName(0) )
Case 5
Call body.AppendText( doc.Termin_Kontakt_Typ(0) )
Case 6
Call body.AppendText( doc.KundenProjektTitel(0) )
Case 7
Call body.AppendText( doc.Termin_cIT_Produkt(0) )
Case 8
Call body.AppendText( doc.Termin_Zielsetzung(0) )
Case 9
Call body.AppendText( doc.Termin_Ergebnis(0) )
End Select
Call body.EndInsert
Call rtNav.FindNextElement( RTELEM_TYPE_TABLECELL ) ' Move to the next table cell
Next
Set ve = vec.getNextEntry(ve)
Loop
End If
finally:
Exit Function
errHandler:
populateTable = False
Dim strErrMsg As String
Select Case Err
Case Else
strErrMsg = "Error #" & Err & Chr$(10) & Error$ & Chr$(10) & "Line #" & Erl & | in sub/function: "| & Lsi_info(2) & |"|
Msgbox strErrMsg, 16, "Unexpected error"
End Select
Resume finally
End Function
Navigation
[0] Themen-Index
[#] Nächste Seite
[*] Vorherige Sete
Zur normalen Ansicht wechseln