添加异步等待对Excel JavaScript API进行编码

问题描述 投票:0回答:1

如何向以下代码添加异步等待?我想传递以下参数“ numOfParts”,然后使用VLOOKUP Excel内置函数从工作簿范围中找出什么finalInspectionPerPart。

/**
   * Inspection (Minutes)
   * @customfunction inspectionMins
   * @param {number} numOfParts 
   * @returns {number} inspectionMins
   */
  function inspectionMins(numOfParts) {
      var finalInspectionPerPart;
      var procEff = 0.72;
    Excel.run(function (context) {
        var range = context.workbook.worksheets.getItem("Sheet1").getRange("A1:B9");
        var finalInspectionPerPart = context.workbook.functions.vlookup(numOfParts, range, 2, false);
        finalInspectionPerPart.load('value');
        return context.sync()
            .then(function () {
            });
    }).catch(errorHandlerFunction);
      return (finalInspectionPerPart / procEff);
  }
javascript excel user-defined-functions office-js
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.