注意:部分文章发布时间较长,可能存在未知因素,购买时建议在本站搜索商家名称,先充分了解商家动态。
交流:唯一投稿邮箱:hostvps@88.com。
脚本加上Google Scripts的定时执行,可以做到每隔一定时间将整个Google Sheets作为附件发到指定邮箱备份。
//////////////
function onOpen() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var menuEntries = [ {name: “Send Email”, functionName: “backupGoogleSpreadsheetAsExcel”}];
ss.addMenu(“Scripts”, menuEntries);
};
function backupGoogleSpreadsheetAsExcel(){
try {
var ss = SpreadsheetApp.getActive();
var url = “https://docs.google.com/feeds/download/spreadsheets/Export?key=” + ss.getId() + “&exportFormat=xlsx”;
var params = {
method : “get”,
headers : {“Authorization”: “Bearer ” + ScriptApp.getOAuthToken()},
muteHttpExceptions: true
};
var blob = UrlFetchApp.fetch(url, params).getBlob();
blob.setName(ss.getName() + “.xlsx”);
MailApp.sendEmail(“收邮箱”, “Google Sheet to Excel”, “The XLSX file is attached”, {attachments: [blob]});
} catch (f) {
Logger.log(f.toString());
}
}
///////////////
转自:https://www.hostloc.com/thread-541812-1-1.html