1
我想写一个word文档,使用DocX库进行c#ms word文档创建。我怎样才能将段落转换成office word文档段落?如何将WPF Rich Textbox内容写入Word文档?
我想写一个word文档,使用DocX库进行c#ms word文档创建。我怎样才能将段落转换成office word文档段落?如何将WPF Rich Textbox内容写入Word文档?
您必须抓取FlowDocument
的每个节点,然后最终将其内容转换为相应的段落,如DocX
库的InsertAfter
方法。
我试过使用DocX
,但将它从WPF转换为Word并不容易。我们结束了使用RTF
到Word
使其正常布局,而不必处理与它实际上看起来像WPF和Word
样品
Table currentTable = CreateDocXTable(table.Columns.Count, table.RowGroups[0].Rows.Count);
if(block is Section)
{
var editableSection = block as Section;
var content = new TextRange(editableSection.ContentStart, editableSection.ContentEnd);
currentTable.Rows[rowIndex].Cells[cellIndex].Paragraphs[0].InsertText(content.Text);
}
布局