【发布时间】:2020-04-01 22:15:10
【问题描述】:
所以,我正在尝试通过应用程序脚本备份谷歌电子表格,因为每个月数据都会发生变化,我想要记录过去的数据。 我可以制作电子表格的副本就好了。
function makeCopy() {
// generates the timestamp and stores in variable formattedDate as year-month-date hour-minute-second
var formattedDate = Utilities.formatDate(new Date(), "GMT", "yyyy-MM-dd' 'HH:mm:ss");
// gets the name of the original file and appends the word "copy" followed by the timestamp stored in formattedDate
var name = SpreadsheetApp.getActiveSpreadsheet().getName() + formattedDate;
// gets the destination folder by their ID. REPLACE xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx with your folder's ID that you can get by opening the folder in Google Drive and checking the URL in the browser's address bar
var destination = DriveApp.getFolderById("I know this is supposed to be the folderID");
// gets the current Google Sheet file
var file = DriveApp.getFileById(SpreadsheetApp.getActiveSpreadsheet().getId())
// makes copy of "file" with "name" at the "destination"
file.makeCopy(name, destination);
}
但是,在我完成一个月后,电子表格中的数据会在一天左右的时间内根据公式发生变化。我只想复制这些值。几个小时以来,我一直在为此挠头,想知道是否有人有任何想法?我不是特别擅长编码,所以,它必须是体面的基本响应。
我的一个想法是复制电子表格中的所有工作表,将它们转换为值,将这些工作表复制到新的电子表格中,然后删除原始电子表格中的这些副本?这会有点乏味,但现在只有 4 个选项卡。 “表格”“银行记录”“交易”和“GLAccounts”
【问题讨论】:
标签: google-apps-script google-sheets