简体   繁体   English

计算应用脚本中的单元格以在谷歌表格中使用

[英]calculate cells in app script to using in google sheet

I have this function and run good:我有这个 function 并且运行良好:

function total(x,y)
    return x + y;
  }

in google sheet I add in any cell =total(A1,B1) and give me result.在谷歌工作表中,我添加了任何单元格=total(A1,B1)并给我结果。

I want to do same that to calculate a lot of cells by this code:我想通过这段代码来计算很多单元格:

function total(x)
    return x;
  }

in google sheet I add in any cell =total(A1:A100) and give me error.在谷歌表中,我添加了任何单元格=total(A1:A100)并给我错误。 any help for that problem.对那个问题的任何帮助。

function myTotal(a) {
  let r = a.flat().filter(e => e && !isNaN(e));
  if(r && r.length ) {
    return r.reduce((a, c) => a += Number(c));
  } else {
    return '';
  }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用谷歌表格中的应用程序脚本在单元格中插入自动数据? - How to inset automatic data in Cells using app script in google sheet? 用于计算连续单元格之间百分比的脚本 Google Sheet - Script to calculate percentage between consecutive cells Google Sheet 使用Google脚本从Google表格中的单元格列表获取数组 - Using Google Script to get an array from a list of cells in google sheet 如何在google sheet app脚本中计算剩余时间 - How to calculate remaining time in google sheet app script 使用谷歌应用脚本将谷歌工作表中的数据拆分到另一张工作表 - Split data in google sheet to another sheet using google app script 使用谷歌应用程序脚本从 MYSQL 数据库中获取数据时,谷歌电子表格中的单元格中缺少某些值 - Some Values are missing in the cells in google spread sheet when fetching the data from MYSQL Database using google app script 在 Google 表格中使用 App Script 格式化文本 - Format Text using App Script in Google sheet 根据其他行中单元格中的值有条件地编辑单元格 - 使用 Google Script 的 Google Sheet - Conditionally edit cells based of the value in cells in other rows - Google Sheet using Google Script 如何使用 Google App Script 将格式化文本从 google sheet 单元格保存到 .rtf? - How to save formatted text from google sheet cells to .rtf with Google App Script? 查找并移动 1 列中以相同字符开头的所有单元格 - google sheet - google app script - finding and moving all cells that are in 1 column that start with the same characters - google sheet - google app script
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM