gpt4 book ai didi

openxml - 创建启用跟踪更改的 OOXML 文档

转载 作者:行者123 更新时间:2023-12-01 12:24:42 29 4
gpt4 key购买 nike

如何创建启用跟踪更改的 .docx?里面有人告诉我word/settings.xml我应该修改 w:proofState但是我发现 OOXML 在线文档中的所有信息都与语法和拼写检查有关,但与启用跟踪更改无关。

最佳答案

它在 word/settings.xml但您要查找的元素是 w:trackRevisions .

要使用 OpenXML SDK 在 C# 中执行此操作,您可以使用 TrackRevisions 类(class)。以下代码将创建一个包含一个段落并打开更改跟踪的文档:

using (WordprocessingDocument package = WordprocessingDocument.Create(filename, WordprocessingDocumentType.Document))
{
// Add a new main document part.
package.AddMainDocumentPart();

//create a body and a paragraph
Body body = new Body();
Paragraph paragraph = new Paragraph();
paragraph.AppendChild(new Run(new Text("This document should have change tracking switched on")));
body.AppendChild(paragraph);
package.MainDocumentPart.Document = new Document(body);

//change tracking code
DocumentSettingsPart documentSettingsPart = package.MainDocumentPart.AddNewPart<DocumentSettingsPart>();
Settings settings = new Settings();
TrackRevisions trackRevisions = new TrackRevisions();
settings.Append(trackRevisions);
documentSettingsPart.Settings = settings;

// Save changes to the main document part.
package.MainDocumentPart.Document.Save();
}

关于openxml - 创建启用跟踪更改的 OOXML 文档,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41188916/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com