Difference between revisions of "AODL example 6"

From Apache OpenOffice Wiki
Jump to: navigation, search
 
Line 34: Line 34:
 
</pre>
 
</pre>
 
Back to the [[AODL_examples|AODL examples]] overview.
 
Back to the [[AODL_examples|AODL examples]] overview.
 +
[[category:Summer of Code 2007]][[category:AODL]]

Revision as of 22:25, 25 June 2007

Create a table and use cell merging

//Create a new text document
TextDocument document = new TextDocument();
document.New();
//Create a table for a text document using the TableBuilder
Table table = TableBuilder.CreateTextDocumentTable(
    document,
    "table1",
    "table1",
    3,
    3,
    16.99,
    false,
    false);

//Fill the cells
foreach(Row row in table.RowCollection) {
    foreach(Cell cell in row.CellCollection) {
        //Create a standard paragraph
        Paragraph paragraph  = ParagraphBuilder.CreateStandardTextParagraph(document);
        //Add some simple text
        paragraph.TextContent.Add(new SimpleText(document, "Cell text"));
        cell.Content.Add(paragraph);
    }
}
//Merge some cells. Notice this is only available in text documents!
table.RowCollection[1].MergeCells(document, 1, 2, true);
//Add table to the document
document.Content.Add(table);
//Save the document
document.SaveTo("simpleTableWithMergedCells.odt");

Back to the AODL examples overview.

Personal tools