| | |
| | | |
| | | |
| | | function SUM(...val){ |
| | | let num = 0; |
| | | let num = null; |
| | | if(val&&val.length>0){ |
| | | val.forEach(item=>{ |
| | | num+=item; |
| | |
| | | return num; |
| | | } |
| | | function MAX(...val){ |
| | | let max = 0; |
| | | let max = null; |
| | | if(val&&val.length>0){ |
| | | val = val.filter(item=>item!=null&&item!=='') |
| | | if(val.length>0){ |
| | | max = Math.max(...val) |
| | | }else{ |
| | | max = null; |
| | | } |
| | | } |
| | | return max; |
| | | } |
| | | function MIN(...val){ |
| | | let min = 0; |
| | | let min = null; |
| | | if(val&&val.length>0){ |
| | | val = val.filter(item=>item!=null&&item!=='') |
| | | console.log(val) |
| | | if(val.length>0){ |
| | | min = Math.min(...val) |
| | | } |
| | | } |
| | | return min; |
| | | } |
| | | |
| | | function AVERAGE(...val){ |
| | | let num = 0; |
| | | let num = null; |
| | | let arr = []; |
| | | if(val&&val.length>0){ |
| | | arr = val.filter(item=>item!=null&&item!=='') |
| | | arr.forEach(item=>{ |
| | | num+=item; |
| | | }) |
| | | if(arr.length>0){ |
| | | return num/arr.length; |
| | | }else{ |
| | | return 0; |
| | | return null; |
| | | } |
| | | }else{ |
| | | return null; |
| | | } |
| | | } |
| | | |
| | |
| | | * @param {Object} cellId |
| | | */ |
| | | function getColumnNameFromId(cellId){ |
| | | try{ |
| | | if (! Array.isArray(cellId)) { |
| | | cellId = cellId.split('-'); |
| | | } |
| | |
| | | } |
| | | letter += String.fromCharCode(65 + (i % 26)); |
| | | return letter + (parseInt(cellId[1]) + 1); |
| | | }catch(e){ |
| | | console.log('error',cellId) |
| | | } |
| | | } |
| | | /** |
| | | * 根据列名获取坐标 |
| | |
| | | * @param {Object} arr |
| | | */ |
| | | function getIdFromColumnName(id, arr) { |
| | | try{ |
| | | // Get the letters |
| | | var t = /^[a-zA-Z]+/.exec(id); |
| | | if (t) { |
| | |
| | | } |
| | | } |
| | | return id; |
| | | }catch(e){ |
| | | console.log('error',id) |
| | | } |
| | | } |
| | | |
| | | // 获取参数列表 |