我们在word office js加载项中有一个奇怪的问题 . 我们无法使用office js api找到日期选择器内容控件的ID,因为目前API仅根据git hub上的以下链接上的注释支持富文本内容控件.. https://github.com/OfficeDev/office-js/issues/228

现在,我们正在尝试应用一种解决方法来克服日期选择器内容控制问题 . 我们正在尝试从文档中的Document.xml中删除以下行,而在运行时打开此文档意味着可以在document.xml中进行更改 .

<w:date w:fullDate="2018-08-27T00:00:00Z"><w:dateFormat w:val="M/d/yyyy" /><w:lid w:val="en-US" /><w:storeMappedDataAs w:val="dateTime" /><w:calendar w:val="gregorian" /></w:date>

我们可以使用来自document.xml的javascript SDK使用开放词xml删除上面的行,但它没有反映在打开的文档中 .

以下是从document.xml中删除日期组件的示例代码 .

return Observable.create((observer) => {
            let W = openXml.W;
            // Open a document that is stored as Flat Opc XML.
            // The document contains some comments.
            let doc = new openXml.OpenXmlPackage(base64Doc);
            // Remove all references to comments.
            var mainPart = doc.mainDocumentPart();
            var mainPartXDoc = mainPart.getXDocument();
            let texttag1 = doc.mainDocumentPart().getXDocument().descendants(W.date);
            console.log(texttag1.getSource());

            new XEnumerable(mainPartXDoc.descendants(W.date)).remove();
            let texttag = doc.mainDocumentPart().getXDocument().descendants(W.date);
            var b64string = doc.saveToBase64();

            console.log(b64string);
            console.log(texttag.getSource());
            observer.next(true);

如何使用打开的文档更新document.xml?