Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用带有HTML文本的docx库创建文档_C#_Novacode Docx - Fatal编程技术网

C# 使用带有HTML文本的docx库创建文档

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

我想使用docx库创建文档(*.docx)。我有一个富文本编辑器中的HTML格式的文本,我想按原样保存它。我找不到任何地方可以得到帮助。我目前的代码是非常基本的,是从那里复制粘贴帮助

我的代码如下所示:

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格式插入文本不同。知道吗?我在另一个线程中找到了解决方案