rtLib — Notes Rich Text Management Library Documentation of rtLib — Notes Rich Text Management Library Download rtLib — Notes Rich Text Management Library FAQ of rtLib — Notes Rich Text Management Library Purchase rtLib — Notes Rich Text Management Library Feedback about rtLib — Notes Rich Text Management Library

Cookbook

Quick table

Start search Mail feedback Back to Description


rtTable rtTableStyle rtColor

add (rtContainer) addNewLine (rtContainer) addNewLine (rTextParagraph) appendStyle appendText (rtContainer) appendText (rTextParagraph) Add (rtCollection) Add (rTextParagraph) AltColor Bold count (rtCollection) Cells Clone (rtCollection) Clone (rtColor) Clone (rtFontstyle) Clone (rtParagraphstyle) Clone (rtStyle) Color (rtFontstyle) Color (rtTableStyle) ColorStyle ColumnCount Columns ColumnSpacing Count (rtContainer) Font FontSize getFirstElement (rtCollection) getFirstElement (rtContainer) getRichTextItem LeftMargin (rtParagraphstyle) LeftMargin (rtTable) LeftMargin (rtTableStyle) MergeCells NotesFont RowCount Rows RowSpacing setAsTemplate setRGB Style TableLayout Typeface Values

Code fragment from sample "Quick table"; see full running samples in downloadable help.
Dim table as New rtTable (4, 5)' 4 rows, 5 columns

' creation of large tables out of views may take a long time using cell-by-cell approach of entering data
' if the table is regular enough, you may use "quick" approach utilizing "template" rows and providing data
table.setAsTemplate 2,2' 2 rows starting with 2nd is template rows; we leave one row for header and one for footer
table.MergeCells 2,2,1,3' merge 1st 3 columns and last 2 in 1st template row; it makes 2 cells (1st row) + 5 cells (2nd row) = 7 cells in template region
table.MergeCells 2,2,4,5
' do the look
' table itself - alternate rows some shade of blue and white
Set table.Style.TableLayout = New rtTableStyle(0)
With table.Style.TableLayout
.LeftMargin = DEFAULT_LEFT_MARGIN' if we use TableLayout style, we must place the table
Set .Color = New rtColor(COLOR_WHITE)
.AltColor.setRGB 200,200,255
.ColorStyle = CDTABLE_ALTERNATINGROWS
End With
table.RowSpacing = 0.1*ONE_CM
table.ColumnSpacing = 0.2*ONE_CM
' define fonts to use
Dim fontTitle as New rtFontStyle(0), fontBody as New rtFontStyle(0), fontBlueBody as rtFontStyle
With fontTitle
.TypeFace = "Times New Roman"
.FontSize = 18
Set .Color = New rtColor(COLOR_RED)' creating new rtColor object with color specified as argument sets it a particular color
.Bold = True
End With
With
fontBody
.FontSize = 9
Set .Color = new rtColor(COLOR_WHITE)
.NotesFont = FONT_HELV
End With
Set fontBlueBody = fontBody.Clone
With fontBlueBody
Set .Color = new rtColor(COLOR_RED)
.Color.setRGB 0,128,255' this will use RGB color and ignore original
.Bold = True
End With

' Format Cells
' we need to place text placeholders - empty text run in each cell and apply formatting
Dim r as Integer, c as Integer
For r = 1 to table.rowCount
For c = 1 to table.columnCount
Set cell = table.cells(r,c)
Set rtp = cell.addNewLine (1)
cell.appendStyle fontBody
cell.appendText ""' it may already contain any text - the new values get pre-pended to existing text
Next c
Next r
' define 2 cells with different fonts - create separate Styles for both
Dim style as New rtStyle(0), style1 as rtStyle
With table.cells (2,3)
Set .getFirstElement(RT_OBJ_TEXTRUN).Style = style' set different styles for cells in first row of repeating region
.TopBorder = 2
End With
Set style1 = style.Clone
With table.cells (2,5)
Set .getFirstElement(RT_OBJ_TEXTRUN).Style = style1
.topBorder = 2
End With
Set style.Font = fontTitle
Set style1.Font = fontBlueBody
' Create a table header
table.MergeCells 1,1,1,5
With table.cells (1,5)
.Content.remove .Content.All' merge has created several empty paragraphs out of the content - remove them
.appendStyle style.Font.Clone
.addNewLine 1
.appendText "Quicktable - Person View"
With .getFirstElement(RT_OBJ_TEXTRUN).Font ' get the font of 1st text run
.FontSize = 24
.Color.setRgb 255 ,255, 255
End With
.topBorder = 2
End With

' Let's dump names
Dim ndbNames as New NotesDatabase ("","names.nsf") ' let's take omnipresent db
Dim vw as NotesView, vwec as NotesViewEntryCollection, vwe as NotesViewEntry
Dim people () as String' this is going to be data array

if Not ndbNames.isOpen then ndbNames.Open "",""
Set vw = ndbNames.getView("($People)")
Set vwec = vw.AllEntries
if vwec.Count>0 then
Redim people (vwec.Count, 6)
Dim cnt as Integer, docPerson as NotesDocument
Set vwe = vwec.getFirstEntry
Do While Not vwe is Nothing and count<252/2
' every person takes 2 rows + header and footer
set docPerson = vwe.document' maybe not the best way to use view navigator and then retrieve the document, but...
people (cnt, 0) = docPerson.FirstName(0) + " " + docPerson.LastName(0)
people (cnt, 1) = docPerson.MailAddress(0)
people (cnt, 2) = "Cell phone:"
people (cnt, 3) = docPerson.CellPhoneNumber(0)
people (cnt, 4) = "Phone:"
people (cnt, 5) = docPerson.OfficePhoneNumber (0)
' leave the last cell empty
cnt = cnt + 1
Set vwe = vwec.getNextEntry (vwe)
Loop
' provide the table with data - table will expand "template area" according to the number of data in values
' total table row limit is 255
table.values = people
End if

' add table - create it's own paragraph
ctxDump.addNewLine 1
ctxDump.add table
ctxDump.addNewLine 1
call ctxDump.getRichTextItem(doc,"Body")