從文本創建DOCX
從文字創建新的 Word 文件也很簡單。 將任何文件結構對象(如段落、表格或章節)傳遞,以實例化一個新的 Word 文件。 最後使用 SaveAs
方法來匯出文件。
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
從文字創建新的 Word 文件也很簡單。 將任何文件結構對象(如段落、表格或章節)傳遞,以實例化一個新的 Word 文件。 最後使用 SaveAs
方法來匯出文件。