javascript - Google表格根据单元格编号添加行具有值的单元格计数
问题描述
- 考虑 colD 包含一些值,我需要根据 col D 值在下面插入行,它应该包括包含值的单元格。Exp:如果单元格值 D 为 1,则不应添加任何行,但如果为 2,则应在下方添加一行,并且应使用 get.dataRange 对所有行进行循环以创建行。提前感谢您的帮助**1]
解决方案
如果要添加新行,请尝试appendRow()方法。
例子:
const ss = SpreadsheetApp.getActiveSpreadsheet();
const sheet = ss.getSheets()[0];
// Appends a new row with 3 columns to the bottom of the
// spreadsheet containing the values in the array
sheet.appendRow(["a man", "a plan", "panama"]);
还有更多方法可以测试,看看:
例子:
const ss = SpreadsheetApp.getActiveSpreadsheet();
const sheet = ss.getSheets()[0];
// Shifts all rows down by three
sheet.insertRows(1, 3);
推荐阅读
- php - PHP 文件成功接收表单数据,未发送到 $_POST[]
- excel - 自动更新具有相关下拉值的单元格
- snowflake-cloud-data-platform - 在数组中运行多个雪花 UDF 的给定参数
- reactjs - 为什么在使用 React 时 useState 会在 onsubmit 事件中清除有效负载数据?这是对服务器端的 POST 请求
- javascript - 类方法作为事件处理程序 Javascript
- node.js - CouchDB 计算所有文档并返回一个数字?
- java - 将 Http-SoapHeader 添加到 org.springframework.ws.WebServiceMessage
- r - 使用多列时 tidyr::expand() 的 dbplyr 调度出现意外错误
- javascript - 调用 URL 时,Angular 浏览器版本返回值为 null
- bash - 使用 Bash 脚本安装和运行软件时“找不到命令”