Office js 当我使用office js api插入和删除范围时,Excel for mac会自动上下滚动

Office js 当我使用office js api插入和删除范围时,Excel for mac会自动上下滚动,office-js,Office Js,我正在使用Excel for mac build 15.37(170712)。我正在开发一个office插件,需要经常插入和删除范围。当我在下面的示例代码中调用run函数时,我看到excelformac会自动上下滚动。这似乎是一种特定于平台的行为。这是因为我在windows上运行时没有看到这种行为。此外,当我使用VBA运行相同的算法时,性能相当慢。当我在Excel中添加和删除范围时,是否有可能在mac中避免这种行为并提高性能 var dispInfo = [["9", "0",

我正在使用Excel for mac build 15.37(170712)。我正在开发一个office插件,需要经常插入和删除范围。当我在下面的示例代码中调用run函数时,我看到excelformac会自动上下滚动。这似乎是一种特定于平台的行为。这是因为我在windows上运行时没有看到这种行为。此外,当我使用VBA运行相同的算法时,性能相当慢。当我在Excel中添加和删除范围时,是否有可能在mac中避免这种行为并提高性能

    var dispInfo =
    [["9", "0", "0", "0", "3", "4", "1"], ["2", "1", "0", "0", "0", "1", "1"], ["2", "1", "0", "0", "0", "1", "1"], ["2", "1", "0", "0", "0", "1", "1"], ["5", "1", "1", "0", "1", "4", "4"], ["5", "1", "1", "0", "1", "4", "4"], ["5", "6", "6", "0", "1", "4", "4"], ["5", "11", "11", "0", "1", "4", "4"], ["5", "16", "16", "0", "1", "4", "4"], ["5", "21", "21", "0", "1", "4", "4"], ["5", "5", "5", "0", "1", "4", "5"], ["5", "11", "11", "0", "1", "4", "5"], ["5", "17", "17", "0", "1", "4", "5"], ["5", "23", "23", "0", "1", "4", "5"], ["5", "29", "29", "0", "1", "4", "5"], ["5", "35", "35", "0", "1", "4", "5"], ["5", "41", "41", "0", "1", "4", "5"], ["5", "47", "47", "0", "1", "4", "5"], ["5", "53", "53", "0", "1", "4", "5"], ["5", "59", "59", "0", "1", "4", "5"], ["5", "65", "65", "0", "1", "4", "5"], ["5", "71", "71", "0", "1", "4", "5"], ["5", "77", "77", "0", "1", "4", "5"], ["5", "83", "83", "0", "1", "4", "5"], ["5", "89", "89", "0", "1", "4", "5"], ["5", "95", "95", "0", "1", "4", "5"], ["5", "101", "101", "0", "1", "4", "5"], ["5", "107", "107", "0", "1", "4", "5"], ["5", "113", "113", "0", "1", "4", "5"], ["5", "119", "119", "0", "1", "4", "5"], ["5", "125", "125", "0", "1", "4", "5"], ["5", "1", "1", "0", "1", "4", "5"], ["5", "7", "7", "0", "1", "4", "5"], ["5", "13", "13", "0", "1", "4", "5"], ["5", "19", "19", "0", "1", "4", "5"]];
    var DIPTypeEnum = [
        "Invalid",
        "InsRows",
        "InsCols",
        "DelRows",
        "DelCols",
        "InsRowRegions",
        "InsColRegions",
        "DelRowRegions",
        "DelColRegions",
        "PasteRowRegions"
    ];

function ConvertToLetter(iCol) 
{      
    var iRemainder = iCol%26;
    var iAlpha = Math.floor(iCol / 26);    

    if(iRemainder === 0) {        
        --iAlpha;        
        iRemainder = 26;
    }

    var retVal = String.fromCharCode(iRemainder + 64); 
    if(iAlpha > 0) {
        return ConvertToLetter(iAlpha) + retVal;
    }
    else {
        return retVal;
    }           
}

function run() {
Excel.run(function (ctx) {
    var sheet = ctx.workbook.worksheets.getActiveWorksheet();
    dispInfo.forEach(function (disp) {
        var op = disp[0];
        var anchor = disp[1];
        var range = {
            "rowStart": disp[2],
            "colStart": disp[3],
            "rowCount": disp[4],
            "colCount": disp[5]
        };
        var times = disp[6];
        var AddDeleteRows = function (del, rowStart, rowCount) {
            var rowStartIndex = rowStart + 1;
            var rowAddr = rowStartIndex + ":" + (rowStartIndex + rowCount - 1);
            var rows = sheet.getRange(rowAddr);
            if (del) {
                rows.delete("Up");
            }
            else {
                rows.insert("Down");
            }
        };

        var AddDeleteCols = function (del, colStart, colCount) {
            var colStartIndex = colStart + 1;
            var colAddr = ConvertToLetter(colStartIndex) + ":" + ConvertToLetter(colStartIndex + colCount - 1);
            var cols = sheet.getRange(colAddr);
            if (del) {
                cols.delete("Left");
            }
            else {
                cols.insert("Right");
            }
        };

        while (times--) {
            switch (DIPTypeEnum[op]) {
                case "Inrows":
                case "InsRowRegions":
                    AddDeleteRows(false, anchor, range.rowCount);
                    break;
                case "DelRows":
                case "DelRowRegions":
                    AddDeleteRows(true, anchor, range.rowCount);
                    break;
                case "InsCols":
                case "InsColRegions":
                    AddDeleteCols(false, anchor, range.colCount);
                    break;
                case "DelCols":
                case "DelRowRegions":
                    AddDeleteCols(true, anchor, range.colCount);
                    break;
                default:
                    break;
            }
        }
    });
    return ctx.sync();
});}