Ms word 为什么LibreOffice没有';在docx文档中不显示altchunk?
我使用Ms word 为什么LibreOffice没有';在docx文档中不显示altchunk?,ms-word,openxml,docx,libreoffice,Ms Word,Openxml,Docx,Libreoffice,我使用OpenXML创建Word文档,并使用AltChunks复制此文档中其他文档的一部分。这里只是一个简单的片段: const string _altChunkID = "AltChunkID1111"; var chunk = mainPart.AddAlternativeFormatImportPart( AlternativeFormatImportPartType.Html, _altChunkID); st
OpenXML
创建Word文档,并使用AltChunks
复制此文档中其他文档的一部分。这里只是一个简单的片段:
const string _altChunkID = "AltChunkID1111";
var chunk = mainPart.AddAlternativeFormatImportPart(
AlternativeFormatImportPartType.Html, _altChunkID);
string html =
@"<html>
<head/>
<body>
<h1>Html Heading</h1>
<p>This is an html document in a string literal.</p>
</body>
</html>";
using (Stream chunkStream = chunk.GetStream(FileMode.Create, FileAccess.Write))
using (StreamWriter stringStream = new StreamWriter(chunkStream))
stringStream.Write(html);
chunk.FeedData(ms);
var altChunk = new AltChunk {Id = _altChunkID};
mainPart.Document
.Body
.InsertAfter(altChunk, mainPart.Document.Body.Elements<Paragraph>().Last());
const string\u altChunkID=“AltChunkID1111”;
var chunk=mainPart.AddAlternativeFormatImportPart(
AlternativeFormatImportPartType.Html,_altChunkID);
字符串html=
@"
Html标题
这是一个字符串文本的html文档
";
使用(Stream chunkStream=chunk.GetStream(FileMode.Create,FileAccess.Write))
使用(StreamWriter stringStream=新StreamWriter(chunkStream))
stringStream.Write(html);
FeedData(ms);
var-altChunk=new-altChunk{Id=\u-altChunkID};
主要部分.文件
.身体
.InsertAfter(altChunk,mainPart.Document.Body.Elements().Last());
它是有效的。我打开Word
,看到这个AltChunk
。但是,LibreOffice
没有向我显示这个AltChunk
。如果我在Word
中打开文档并在LibreOffice
开始显示AltChunk
时保存,则
那我做错了什么?为什么
Microsoft Word
正确显示文档而LibreOffice
不正确?我能猜一下吗?这种行为可能是因为下载页面上写着“Open XML SDK 2.5 for Microsoft Office”(不适用于LibreOffice)?@johnson Woah太有趣了,我忍不住笑了。听着,当LibreOffice
不显示文档的一部分时,我已经解决了几个问题。还有同样的情况,更可能是我在代码上犯了错误,那些20年来一直在做LibreOffice
的家伙。我不是开玩笑,我只是猜测而已。很高兴结果很有趣。然而,当我将Word中的一个文档保存为文本OpenDocument(ODT)时,在同一个Word无法打开它之后,我也会努力说服自己我犯了一个错误(并且没有针对开放办公室的阴谋)。不管怎样,我祝你好运!我无能为力——我使用LibreOffice的机制和它的API来完成同样的任务。但是,如果你能找到这场麻烦的原因——仁慈一点,让我们一起来know@JohnSUN我花了一天时间寻找解决方案,但没有结果。猜猜是时候转移到其他api了。萨奇。