Domino 9 und frühere Versionen > ND8: Entwicklung

Tabellenzeile anfügen und befüllen

<< < (2/2)

hupfi:
So etwas verspätet folgt nun auch der Code meiner Tabellenbefüllung:


--- Code: ---Set rtiBody = MailDoc.GetFirstItem( "Body" )
rtiBody.AddNewline(1)

'First Entry ?
If  ScriptError = False Then

'Erstellen der ersten zwei Tabellenzeilen und befüllen

rtiBody.AppendText( TEXTERROR )

Set styles(1) = session.CreateRichTextParagraphStyle
Set styles(2) = session.CreateRichTextParagraphStyle
Set styles(3) = session.CreateRichTextParagraphStyle
Set styles(4) = session.CreateRichTextParagraphStyle
Set styles(5) = session.CreateRichTextParagraphStyle

styles(1).LeftMargin = 0
styles(1).SpacingAbove = SPACING_ONE_POINT_25
styles(1).FirstLineLeftMargin = 0
styles(1).RightMargin = RULER_ONE_INCH*2.5
styles(1).Alignment = ALIGN_LEFT
styles(2).LeftMargin = 0
styles(2).SpacingAbove = SPACING_ONE_POINT_25
styles(2).FirstLineLeftMargin = 0
styles(2).RightMargin = RULER_ONE_INCH*2.5
styles(2).Alignment = ALIGN_LEFT
styles(3).LeftMargin = 0
styles(3).SpacingAbove = SPACING_ONE_POINT_25
styles(3).FirstLineLeftMargin = 0
styles(3).RightMargin = RULER_ONE_INCH*2.5
styles(3).Alignment = ALIGN_LEFT
styles(4).LeftMargin = 0
styles(4).SpacingAbove = SPACING_ONE_POINT_25
styles(4).FirstLineLeftMargin = 0
styles(4).RightMargin = RULER_ONE_INCH*2.5
styles(4).Alignment = ALIGN_LEFT
styles(5).LeftMargin = 0
styles(5).SpacingAbove = SPACING_ONE_POINT_25
styles(5).FirstLineLeftMargin = 0
styles(5).RightMargin = RULER_ONE_INCH*1.5
styles(5).Alignment = ALIGN_LEFT
Call rtiBody.AppendTable(2,5,,,styles)

Set rtnav = rtiBody.CreateNavigator
Call rtnav.FindLastElement( RTELEM_TYPE_TABLE)
Set rtt = rtnav.GetElement

Call rtnav.FindNextElement( RTELEM_TYPE_TABLECELL, 1 )
Call rtiBody.BeginInsert(rtnav)
Call rtiBody.AppendText( "Name" )
Call rtiBody.EndInsert

Call rtnav.FindNextElement( RTELEM_TYPE_TABLECELL )
Call rtiBody.BeginInsert(rtnav)
Call rtiBody.AppendText( "DocType" )
Call rtiBody.EndInsert

Call rtnav.FindNextElement( RTELEM_TYPE_TABLECELL )
Call rtiBody.BeginInsert(rtnav)
Call rtiBody.AppendText( "ErrorMessage" )
Call rtiBody.EndInsert

Call rtnav.FindNextElement( RTELEM_TYPE_TABLECELL )
Call rtiBody.BeginInsert(rtnav)
Call rtiBody.AppendText( "ErrorLine" )
Call rtiBody.EndInsert

Call rtnav.FindNextElement( RTELEM_TYPE_TABLECELL )
Call rtiBody.BeginInsert(rtnav)
Call rtiBody.AppendText( "DocLink" )
Call rtiBody.EndInsert

Call rtnav.FindNextElement( RTELEM_TYPE_TABLECELL, 1 )
Call rtiBody.BeginInsert(rtnav)
Call rtiBody.AppendText("Name")
Call rtiBody.EndInsert

Call rtnav.FindNextElement( RTELEM_TYPE_TABLECELL )
Call rtiBody.BeginInsert(rtnav)
Call rtiBody.AppendText( "DocType" )
Call rtiBody.EndInsert

Call rtnav.FindNextElement( RTELEM_TYPE_TABLECELL )
Call rtiBody.BeginInsert(rtnav)
Call rtiBody.AppendText( "ErrorMessage" )
Call rtiBody.EndInsert

Call rtnav.FindNextElement( RTELEM_TYPE_TABLECELL )
Call rtiBody.BeginInsert(rtnav)
Call rtiBody.AppendText( "ErrorLine" )
Call rtiBody.EndInsert

Call rtnav.FindNextElement( RTELEM_TYPE_TABLECELL )
Call rtiBody.BeginInsert(rtnav)
Call rtiBody.AppendDocLink( targetDoc, "" )
Call rtiBody.EndInsert

Else

'hinzufüngen einer weiteren Tabellenzeile

Set rtnav = rtiBody.CreateNavigator
Call rtnav.FindLastElement( RTELEM_TYPE_TABLE )
Set rtt = rtnav.GetElement
rtt.AddRow

Call rtnav.FindNextElement( RTELEM_TYPE_TABLECELL )
Call rtiBody.BeginInsert(rtnav)
Call rtiBody.AppendText( "Name" )
Call rtiBody.EndInsert

Call rtnav.FindNextElement( RTELEM_TYPE_TABLECELL )
Call rtiBody.BeginInsert(rtnav)
Call rtiBody.AppendText( "DocType" )
Call rtiBody.EndInsert

Call rtnav.FindNextElement( RTELEM_TYPE_TABLECELL )
Call rtiBody.BeginInsert(rtnav)
Call rtiBody.AppendText( "ErrorMessage" )
Call rtiBody.EndInsert

Call rtnav.FindNextElement( RTELEM_TYPE_TABLECELL )
Call rtiBody.BeginInsert(rtnav)
Call rtiBody.AppendText( "ErrorLine" )
Call rtiBody.EndInsert

Call rtnav.FindNextElement( RTELEM_TYPE_TABLECELL )
Call rtiBody.BeginInsert(rtnav)
Call rtiBody.AppendDocLink( targetDoc, "" )
Call rtiBody.EndInsert

End If

--- Ende Code ---

Mit diesem springe ich jedoch vor dem befüllen der neuen Werte in die erste Zeile.
Wie kann ich dies verhindern und bewerkstelligen, dass ich die letzte neu hinzugefügte Tabellenzeile befüllen kann?


Gruß Hupfi

Ralf_M_Petter:
Hm das ist der falsche Code, du wolltest den Code posten in dem der Fehler auftritt. Der Code wie er jetzt ist kann gar nicht funktionieren, da du dich immer wieder auf die erste Zeile positionierst. Ich würde als auf die letzte Zelle positionieren mit
Call rtnav.FindLastElement( RTELEM_TYPE_TABLE_CELL )

Da du aber von diesem rtnav dann kein getElement machen kannst, da du dann die Fehlermeldung erhälst. Brauchst du einen zweiten Richtextnavigator mit dem du die Tabelle erweitern kannst.

Das ganze sollte dann also so aussehen.
Call rtnav.FindLastElement( RTELEM_TYPE_TABLE_CELL )
Call rtnav2.FindLastElement( RTELEM_TYPE_TABLE )
Set rtt =rtnav2.getElement
rtt.AddRow
.....

Ich habe es zwar nicht probiert, aber so würde ich es machen.

Grüße

Ralf

hupfi:
Vielen Danke für deine Tipps Ralf,

Habe es ausprobiert es funktioniert.

Ralf_M_Petter:
Bitte nichts zu danken.

Grüße

Ralf

Navigation

[0] Themen-Index

[*] Vorherige Sete

Zur normalen Ansicht wechseln