Google App Script GAS工作表中的上次修改日期 [英] Last modified date in Google App Script GAS sheets
问题描述
我正在尝试从我正在开发的GAS附件中获取工作表的最后修改日期.
I am trying to get the last modified date of a sheet from a GAS add on which I am developing.
我当前的想法是获取云端硬盘修订版列表,然后获取最后一个值.对于仅进行最后一次修改似乎有点矫kill过正,我也担心,如果此链接建议的修订数量超过1000,这会破坏.
My current idea is to get the Drive revision list and then take the last value. This seems a bit overkill for just getting the last modified, I am also worried that this will break if the number of revisions exceeds 1000 as per this link suggests.
https://developers.google.com/drive/api/v3/reference/revisions/list
理想情况下,我想知道范围也发生了变化,但是我认为这是不可能的.
Ideally I would like to know the range which has changed too, but I do not think this is possible.
我无法使用 onEdit
事件,因为我想跟踪未安装该加载项的用户所做的编辑.
I cannot use the onEdit
event because I would like to track edits made by users who have not installed the add-on.
var fileId = SpreadsheetApp.getActiveSpreadsheet().getId();
var revisions = Drive.Revisions.list(fileId);
var revisionLength = revisions.items.length;
if(revisionLength > 0){
var revision = revisions.items[revisionLength-1];
var date = new Date(revision.modifiedDate);
Logger.log(date.toString());
}
推荐答案
我相信您可以按照以下步骤进行操作
I believe you can do that as follow
var lastUpdated = DriveApp.getFileById(fileId).getLastUpdated();
请参见函数参考
这篇关于Google App Script GAS工作表中的上次修改日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!