Difference between revisions of "AODL example 2"

From Apache OpenOffice Wiki
Jump to: navigation, search
m
 
Line 1: Line 1:
 
<b>Create a spreadsheet document and add a table</b>
 
<b>Create a spreadsheet document and add a table</b>
<pre>
+
<syntaxhighlight lang="c">
 
//Create new spreadsheet document
 
//Create new spreadsheet document
 
SpreadsheetDocument spreadsheetDocument = new SpreadsheetDocument();
 
SpreadsheetDocument spreadsheetDocument = new SpreadsheetDocument();
Line 24: Line 24:
 
spreadsheetDocument.TableCollection.Add(table);
 
spreadsheetDocument.TableCollection.Add(table);
 
spreadsheetDocument.SaveTo("F:\tests\simple.ods");
 
spreadsheetDocument.SaveTo("F:\tests\simple.ods");
</pre>
+
</syntaxhighlight>
 
Back to the [[AODL_examples|AODL examples]] overview.
 
Back to the [[AODL_examples|AODL examples]] overview.
 
[[category:Summer of Code 2007]][[category:AODL]]
 
[[category:Summer of Code 2007]][[category:AODL]]

Latest revision as of 12:33, 22 May 2022

Create a spreadsheet document and add a table

//Create new spreadsheet document
SpreadsheetDocument spreadsheetDocument = new SpreadsheetDocument();
spreadsheetDocument.New();
//Create a new table
Table table = new Table(spreadsheetDocument, "First", "tablefirst");
//Create a new cell, without any extra styles 
Cell cell = table.CreateCell("cell001");
cell.OfficeValueType = "string";
//Set full border
cell.CellStyle.CellProperties.Border = Border.NormalSolid;           
//Add a paragraph to this cell
Paragraph paragraph = ParagraphBuilder.CreateSpreadsheetParagraph(spreadsheetDocument);
//Add some text content
paragraph.TextContent.Add(new SimpleText(spreadsheetDocument, "Some text"));
//Add paragraph to the cell
cell.Content.Add(paragraph);
//Insert the cell at row index 2 and column index 3
//All need rows, columns and cells below the given
//indexes will be build automatically.
table.InsertCellAt(2, 3, cell);
//Insert table into the spreadsheet document
spreadsheetDocument.TableCollection.Add(table);
spreadsheetDocument.SaveTo("F:\tests\simple.ods");

Back to the AODL examples overview.

Personal tools