|
- function run(){
- const [arr1, arr2] = ['B6:BR17','B19:BR29'].map(addr => Range(addr).Value2)
- const sums = Array(arr1[0].length + 4).fill(0), res = []
- const f = v => { // forEach回调
- let nums = Array(3).fill(0)
- v.forEach((n, i) => n !== undefined && (nums[i % 3] += v[i], sums[i] += v[i]))
- nums.concat(eval(nums.join('+'))).forEach((n, i) => sums[sums.length - 4 + i] += n)
- res.push(nums)
- }
- // 单纯是图省事,直接在字符串原型上扩充
- String.prototype.writeDatas = function(x) { Range(this).Resize(x.length, x[0].length).Value2 = x }
- arr1.forEach(f)
- 'BS6'.writeDatas(res) // [BS6:BV17]
- 'B18'.writeDatas([sums]) // 陪餐费合计
- const prevSums = sums.map((n, i , a) => (a[i] = 0, n)) // 保存到其它数组对象上,sums中的元素归零
- res.length = 0
- arr2.forEach(f)
- 'BS19'.writeDatas(res) // [BS19:BV29]
- 'B30'.writeDatas([sums]) // 师傅就餐合计
- sums.map((n, i) => n + prevSums[i])
- 'B31'.writeDatas([sums]) // 同餐同费合计
- }
复制代码
|
评分
-
1
查看全部评分
-
|