作者ppppppppp (凹嗚嗚)
看板Google
標題Re: [詢問] 算表使用google app script可否輸出檔案
時間Fri Jun 24 12:48:19 2022
我有用過一個輸出成pdf檔的語法
給你參考一下
應該
function convertSheetToPdf() {
var sheetId = "這裡輸入你的試算表id";
//var SpreadSheet = SpreadsheetApp.openByUrl('
https://docs.google.com/spreadshee
ts/d/你的試算表id/edit#gid=0'); 這行應該不用
var destination = DriveApp.getFolderById("這裡輸入你要存放輸出的pdf的資料夾id"
);
var url = "
https://docs.google.com/feeds/download/spreadsheets/Export?key=" +
sheetId + "&exportFormat=pdf";
var params = {
method : "get",
headers : {"Authorization": "Bearer " + ScriptApp.getOAuthToken()},
muteHttpExceptions: true
};
var blob = UrlFetchApp.fetch(url, params).getBlob();
blob.setName("你要的檔案名稱" + ".pdf");
destination.createFile(blob);
}
沒記錯的話我當初應該是參考這個網站的語法
https://bit.ly/3OEScjS
看底下Answer那裡
※ 引述《terrylove12 (空洞)》之銘言
: 想詢問會寫google app script的高手
: google 算表有沒有辦法輸出檔案
: 過去我常用excel +vba去做資料整理
: 然後透過vba的open & print 去輸出其他程式可以吃的txt
: 如果想把該功能線上化
: 請問google app script 可否做到一樣的事情
----
Sent from
BePTT on my Samsung SM-G9980
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 36.236.50.113 (臺灣)
※ 文章網址: https://webptt.com/m.aspx?n=bbs/Google/M.1656046102.A.D3C.html
1F:→ skybrest: 推 06/28 21:13