Create DOCX From Text
Creating a new Word document from text is also simple. Pass any document structure object, such as a paragraph, table, or section, to instantiate a new Word document. Finally, use the SaveAs
method to export the document.
using IronWord; using IronWord.Models; // Create textrun Text textRun = new Text("Sample text"); Paragraph paragraph = new Paragraph(); paragraph.AddChild(textRun); // Create a new Word document WordDocument doc = new WordDocument(paragraph); // Export docx doc.SaveAs("document.docx");
Imports IronWord Imports IronWord.Models ' Create textrun Private textRun As New Text("Sample text") Private paragraph As New Paragraph() paragraph.AddChild(textRun) ' Create a new Word document Dim doc As New WordDocument(paragraph) ' Export docx doc.SaveAs("document.docx")
Install-Package IronWord
Creating a new Word document from text is also simple. Pass any document structure object, such as a paragraph, table, or section, to instantiate a new Word document. Finally, use the SaveAs
method to export the document.
9 .NET API products for your office documents