| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 计算幂 |
| | | * |
| | | * @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) { |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | |
| | | // 获取单元格对应值 |
| | | 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] |
| | | } |
| | | } |
| | | } |
| | | // 解析公式参数,特别是带:的 |