前提
GAS超初心者です。
ご教授いただけますと大変幸いです。
実現したいこと
スプレッドシートのシートごとにエクセルファイルを生成し、GoogleDriveに保存したい。
エラー
なぜかコードのようなものが書かれたHTMLファイルが生成されてしまう。
参考サイト
https://note.com/taraco123/n/n53b662bcf8fc
(これはPDF生成版)
function myFunction() { const ss = SpreadsheetApp.getActiveSpreadsheet(); const key = ss.getId(); const sheets = ss.getSheets(); const token = ScriptApp.getOAuthToken(); const folder = DriveApp.getFolderById("★フォルダIDを記載"); sheets.forEach(function(sheet){ const gid = sheet.getSheetId(); const url = "https://docs.google.com/spreadsheets/d/" + key + "/export?gid=" + gid + "&exportFormat=xlsx”; const options = { headers:{"Authorization":"Bearer " + token} } const response = UrlFetchApp.fetch(url,options); const blob = response.getBlob(); blob.setName(sheet.getName()); folder.createFile(blob); }); }

回答1件
あなたの回答
tips
プレビュー