【发布时间】:2014-04-12 06:40:50
【问题描述】:
我有一个 Google 电子表格,我想在编辑尚未设置日期的行时自动设置“日期”单元格的值。据我所知 Google Sheets API 以及 GoogleScript 的工作原理,我认为这应该可以工作,但它甚至从未设置调试单元! 我在这里做错了什么?
/**
* Automatically puts the current date in the first column of the edited row
*/
function onEdit(event){
var sheet = event.source.getActiveSheet();
var debugCell = sheet.getCell(10,10);
debugCell.setValue("DEBUG CELL"); // if anything works, this should show up... but it doesn't :C
var editedCell = sheet.getActiveCell();
var dateCol = 0;
var dateCell = sheet.getCell(editedCell.getRow(), dateCol);
debugCell.setValue(editedCell.getColumn());
if(!dateCell.getValue() && editedCell.getColumn() != dateCol){
dateCell.setValue(new Date());
}
}
【问题讨论】:
标签: javascript google-sheets spreadsheet