licp
2024-07-04 eb6479e7df9692aa3d79f36631c13c3f8b4b5797
src/util/excelFountion.js
@@ -133,6 +133,27 @@
  }
}
/**
 * 计算幂
 *
 * @param str 字符串形式的幂表达式,例如"2^3"
 * @returns 返回计算后的幂值,如果表达式无效则返回null
 */
function CalculatePower(str){
  try {
    if(str&&str.includes('^')){
      let arr = str.split('^');
      if(arr&&arr.length>1){
        return Math.pow(arr[0],arr[1]);
      }else{
        return null;
      }
    }
  } catch (error) {
  }
}
/**
@@ -294,8 +315,13 @@
    // 获取单元格对应值
    let arr = getAllCell(f)
    for (var a in comValue) {
      if(comValue[a]!=='undefine'&&comValue[a]!=='null'&&comValue[a]!==undefined){
        arr[a] = comValue[a]
      if(comValue[a]!=='undefined'&&comValue[a]!=='null'&&comValue[a]!==undefined){
        if(typeof(comValue[a])=='string'&&comValue[a].includes('^')){
          // 计算幂次
          arr[a] = CalculatePower(comValue[a])
        }else{
          arr[a] = comValue[a]
        }
      }
    }
    // 解析公式参数,特别是带:的