Office365 Office 365是否有JS API来操作Word文档中的段落、表格或文本?

Office365 Office 365是否有JS API来操作Word文档中的段落、表格或文本?,office365,Office365,Office 365是否有Javascript API来操作Word文档中的段落、表格或文本 我想使用API搜索文档中的某些文本/字段并替换它们。一个选项是将文档获取为,然后使用遍历和替换对象。Psudo代码: function getParas() { var documentText = null; Office.context.document.getFileAsync("compressed", function (result) { if (re

Office 365是否有Javascript API来操作Word文档中的段落、表格或文本


我想使用API搜索文档中的某些文本/字段并替换它们。

一个选项是将文档获取为,然后使用遍历和替换对象。Psudo代码:

    function getParas() {
    var documentText = null;
    Office.context.document.getFileAsync("compressed", function (result) {
        if (result.status == "succeeded") {
            //Get the file
            var myFile = result.value;
            myFile.getSliceAsync(0, function (resultSlice) {
                if (result.status == "succeeded") {
                    //We got the file slice. Now we will encode the data and post to a service
                    documentText = OSF.OUtil.encodeBase64(resultSlice.value.data);
                    var doc = new openXml.OpenXmlPackage(documentText);

                    // Replace the first paragraph in the document with the new paragraph.
                    var allParas = doc.mainDocumentPart().getXDocument().descendants(W.p);
                    // .firstOrDefault().toString();

                    for (var i = 0; i < allParas.count(); i++)
                    {
                        var Para = allParas.elementAt(i);
                        var ParaText = Para.toString();
                        app.showNotification(ParaText);
                    }

                }
            });
            myFile.closeAsync();
        }
    })
}

在堆栈溢出中搜索API/库是离题的。尝试Google/MSDN。已经完成,但没有好结果。@Raptor