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