0

我正在尝试读取标头ooxml,对其进行修改并插入回标头。但是在插入时,它以某种方式在标题中添加了额外的一行。即使我只是阅读了 ooxml 并将其插入而没有任何更改,它也会在标题中添加一个额外的行。我错过了什么?

这是我的代码

Word.run(function (context) {

        var docSections = context.document.sections; 

        context.load(docSections, 'body/style');

        return context.sync().then(function () {                


            // get header
            var header = docSections.items[0].getHeader("primary");


            var ooxml = header.getOoxml();

            // another sync to get the OOXML value
            return context.sync().then(function () {


                // get ooxml value and insert it
                var headerVal = ooxml.value;
                header.insertOoxml(headerVal, 'Replace');


                return context.sync().then(function () {
                    callBackFunc({
                        isError: false
                    });
                });

            });
        });
    })
4

1 回答 1

0

好的,你在 MSI。在 MSI SKU 中,这是一个已知问题,已针对 Office 365 SKU 修复,作为 1.2 API 的一部分提供。如果您的目标版本是 MSI,那么您需要在插入 OOXML 后删除该段落(您可以在此之前检查是否支持 1.2)

于 2018-03-20T19:45:18.753 回答