|
考虑最坏情况(Google账号被封),可能不是刚需。
脚本加上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());
- }
- }
- ///////////////
复制代码 |
|