【问题标题】:Convert a specific google sheets tab into a pdf将特定的谷歌表格标签转换为 pdf
【发布时间】:2021-12-20 11:54:33
【问题描述】:

对于我目前正在进行的一个项目,我正在尝试找到一种方法,让我可以使用 javascript 将特定的 google 表格标签转换为 pdf

【问题讨论】:

  • 请提供足够的代码,以便其他人更好地理解或重现问题。

标签: javascript google-sheets


【解决方案1】:

你必须在这个脚本中输入你自己的 id

function savePDF(){

  const docID = '______id of the spreadsheet________';
  const feuilleID = '___id of the sheet______';
  const dossier = DriveApp.getFolderById('______id of the folder_______');
  const fichier = 'name of the file.pdf'

  const url = 'https://docs.google.com/spreadsheets/d/' + docID + '/export?';
  const exportOptions =
    'exportFormat=pdf&format=pdf' + 
    '&size=A4' + 
    '&portrait=true' +
    '&fitw=false' +
    '&sheetnames=false&printtitle=false' +
    '&pagenumbers=false&gridlines=false' +
    '&fzr=false' +
    '&gid=' + feuilleID;
  var params = {method:"GET",headers:{"authorization":"Bearer "+ ScriptApp.getOAuthToken()}};
  var reponse = UrlFetchApp.fetch(url + exportOptions, params).getBlob(); 
  dossier.createFile(reponse.setName(fichier));
}

【讨论】:

    猜你喜欢
    • 2013-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多