我如何使 wordml 成为只读的。
有任何想法吗??
将以下内容添加到您的 WordML 文档将告诉 Word 将其内容视为只读:
<w:wordDocument>
<w:docPr>
<w:documentProtection w:edit="read-only" w:enforcement="on" w:unprotectPassword="5349CC3D"/>
</w:docPr>
</w:wordDocument>
w:unprotectPassword 在此示例中为“1234”,但此属性不是必需的。如果不包含解锁密码,Word 将允许用户只关闭文档的只读状态,而无需挑战他们。
希望对您有所帮助,并且是您正在寻找的东西!
如果您使用的是 Open XML SDK 2.0,您可以在 open 方法调用的第二个参数中将文件指定为只读:
// false is the read-only property
using (var wordprocessingDocument = WordprocessingDocument.Open(documentFileName, false))
{
// Do work here
}