This agent creates a document, creates a basic table in a rich
text item in the document, then displays the table properties and
populates the table.import lotus.domino.*;
public class JavaAgent extends AgentBase {
public void NotesMain() {
try {
Session session = getSession();
AgentContext agentContext = session.getAgentContext();
// (Your code goes here)
Database db = agentContext.getCurrentDatabase();
// Create document with Body item
Document doc = db.createDocument();
doc.appendItemValue("Form", "MainTopic");
doc.appendItemValue("Subject", "Table 4 x 3");
RichTextItem body = doc.createRichTextItem("Body");
// Create table in body item
int rowCount = 4;
int columnCount = 3;
body.appendTable(rowCount, columnCount);
// Print table properties
RichTextNavigator rtnav = body.createNavigator();
RichTextTable rttable = (RichTextTable)rtnav.getFirstElement(
RichTextItem.RTELEM_TYPE_TABLE);
System.out.println("Table properties:");
System.out.println("\tRows = " + rttable.getRowCount());
System.out.println("\tColumns = " + rttable.getColumnCount());
System.out.println("\tCStyle = " + rttable.getStyle());
System.out.println("\tColor = " + rttable.getColor().getNotesColor());
System.out.println("\tColor = " + rttable.getAlternateColor().getNotesColor());
// Populate table
rtnav.findFirstElement(RichTextItem.RTELEM_TYPE_TABLECELL);
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 3; j++) {
body.beginInsert(rtnav);
body.appendText("Row " + (i + 1) + ", column " + (j + 1));
body.endInsert();
rtnav.findNextElement();
}
}
// Save document
doc.save(true, true);
} catch(Exception e) {
e.printStackTrace();
}
}
}