【发布时间】:2017-03-25 03:38:04
【问题描述】:
我希望每天凌晨 1 点从外部来源将一些数据提取到 Google 表格中。进口产品的数量会有所不同。
然后我希望在数据上传完成后按价格对数据进行排序,这将是凌晨 1.05 左右。
我发现可以定时运行 Google 表格的功能。
我需要什么脚本来按价格对数据进行排序,所以每天早上运行脚本后最便宜的项目是第 2 行。
要在 Google 表格中手动执行此操作 - *突出显示第 2 行到 、数据、排序范围、按列 I 排序、A - Z
这将如何转化为函数?定时功能看起来很容易用作触发器(尽管设定时间不可行;似乎只有一个小时范围)
这是共享表
https://docs.google.com/spreadsheets/d/1hRW92xesCZzrTRU8DzrdJ_XtrQoJbbNhA3nVT452 apE/edit?usp=sharing
解决方案 - 感谢 Ed & Cooper
首先,手动冻结第一行。 (搜索冻结)https://support.google.com/docs/answer/54813?hl=en
function myFunction() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
// Sorts the sheet by the column I - the ninth across - , in ascending order
sheet.sort(9);
}
【问题讨论】:
-
通过将正确答案标记为已接受的答案来记入正确答案
标签: javascript sorting google-apps-script google-sheets