1
我正在通過其標記從docx讀取內容控件。我想阻止對它的訪問(用戶將無法編輯內容)。我怎樣才能做到這一點? 這是我從DOCX文檔得到控制其標籤名稱代碼:如何阻止對內容控件的訪問 - 打開xml
using (WordprocessingDocument wordDocTarget = WordprocessingDocument.Open(targetFilePath, true))
{
MainDocumentPart mainPartSource = wordDocSource.MainDocumentPart;
SdtBlock sdtBlock = mainPartSource.Document.Body.Descendants<SdtBlock>().Where(r => r.SdtProperties.GetFirstChild<Tag>().Val == "myTagName").SingleOrDefault();
// rest of my code (editing inner text)
}
謝謝!它工作的很棒:)我添加了sdtBlock.SdtProperties.RemoveAllChildren();將取消阻止SdtBlock。 –
daniell89