從文字建立 DOCX 檔案
從文字建立新的Word文件也很簡單。 傳遞任何文件結構物件,例如section,以實例化新的Word文件。 最後,使用SaveAs方法匯出文件。
準備開始了嗎?
Nuget 下載 48,355 | 版本: 2026.7 剛剛發布
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文件也很簡單。 傳遞任何文件結構物件,例如section,以實例化新的Word文件。 最後,使用SaveAs方法匯出文件。