C# 使用带有HTML文本的docx库创建文档
我想使用docx库创建文档(*.docx)。我有一个富文本编辑器中的HTML格式的文本,我想按原样保存它。我找不到任何地方可以得到帮助。我目前的代码是非常基本的,是从那里复制粘贴帮助 我的代码如下所示:C# 使用带有HTML文本的docx库创建文档,c#,novacode-docx,C#,Novacode Docx,我想使用docx库创建文档(*.docx)。我有一个富文本编辑器中的HTML格式的文本,我想按原样保存它。我找不到任何地方可以得到帮助。我目前的代码是非常基本的,是从那里复制粘贴帮助 我的代码如下所示: private string CreateDocumentFromText() { string filePath= Server.MapPath("../DocXExample.docx"); var document = Novacode.DocX.Create(filePa
private string CreateDocumentFromText()
{
string filePath= Server.MapPath("../DocXExample.docx");
var document = Novacode.DocX.Create(filePath);
document.InsertParagraph("<b>Test</b>");
document.Save();
return fileName;
}
私有字符串CreateDocumentFromText()
{
字符串filePath=Server.MapPath(“../DocXExample.docx”);
var document=Novacode.DocX.Create(文件路径);
文件。插入段落(“测试”);
document.Save();
返回文件名;
}
文件内容如下:
<b>Test</b>
测试
鉴于我希望它是:
测试必须将其转换为xml元素。
尝试DocumentFormat.OpenXml库你能指出一些例子吗,因为当我查找它时,我发现我必须将它作为外部内容插入,但是用户体验将与以word格式插入文本不同。知道吗?我在另一个线程中找到了解决方案