8. Create New Documents //Create a new text document TextDocument document = new TextDocument () ; document.New () ; //Create a standard paragraph using the ParagraphBuilder Paragraph paragraph = ParagraphBuilder.CreateStandardTextParagraph(document); //Add some simple text paragraph.TextContent.Add( new SimpleText ( document, "OpenOffice.org Conference" ) ) ; //Add the paragraph to the document document.Content.Add ( paragraph ) ; //Save document.SaveTo ( "simple.odt" ) ;
9. Modify Existing Documents //Create a new text document object TextDocument document = new TextDocument () ; //Load a text document document.Load (" OOoCon2007.odt" ) ; //Search for a text area control with the id = headline ODFTextArea headlineCtl = document.FindControlById (" headline ") as ODFTextArea; if ( headlineCtl != null) { //Set a new value for the found control headlineCtl.CurrentValue = "OpenOffice.org Conference " ; } //Save modified document document.SaveTo (" OOoCon2007.odt" ) ;