我希望一个脚本可以在单元格中插入学生ID号,然后下载&将工作表作为PDF导出,用学生的ID命名文件

发布于 2025-02-03 02:28:22 字数 421 浏览 4 评论 0原文

我在Google表中有一份学生进度报告,该报告基于在Cell B5中输入的唯一学生ID,该数据(使用查询,过滤器,Vlookups,Sparklines等)填充了数据(使用查询,Vookups,Sparklines等)。作为老师,这对我来说非常有用,可以在屏幕上单独向学生展示。但是,我的学校想使用报告与所有学生和父母进行交流。

对于一千名学生来说,这几乎是不可能的。有没有办法编写可以在B5中自动输入学生ID的脚本,将其下载为PDF并用学生ID号命名文件?然后重复下一个学生ID的过程?

我一直在努力做这项工作,现在就如何与学生和父母共享此信息(在保护隐藏板中发现的全校数据等)方面正在撞到砖墙。我知道我的方式围绕公式,甚至更“高级”,但是编写脚本不是我可以做的。如果我能找到一个接近我想完成的事情的人,我知道足以进行小型自定义,但是我真的迷失了这一点。如果有人有任何想法或可以帮助我,我会很感激!

I have a Student Progress Report in Google Sheets that populates data (using queries, filters, vlookups, sparklines, etc.) based on a unique student ID that is entered in cell B5. This works great for me as a teacher to show to student individually on the screen. However, my school wants to use the report to communicate to all students and parents.

This would pretty much be logistically impossible for a thousand students. Is there a way to write a script that would automatically enter a student ID in B5, download it as a PDF and name the file with the student ID number? And then repeat the process for the next student ID?

I've been working so hard to make this work and am hitting a brick wall now in terms of how to share this information with students and parents (while protecting privacy, etc. of whole-school data that is found in hidden sheets). I know my way around formulas, even more "advanced" ones, but writing scripts is not something I can do yet. If I can find one that is close to what I want to accomplish, I know enough to make small customizations, but I'm really lost on this one. I'd be so appreciative if anyone had any ideas or could help me!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

风和你 2025-02-10 02:28:22

这是草稿

function saveAllAsPDF(){
  const ss = SpreadsheetApp.getActiveSpreadsheet();
  const sh1 = ss.getSheetByName('IMPORT Masterlist');       
  const sh2 = ss.getSheetByName('Student Progress Report');            
  sh1.getRange('A2:A'+sh1.getLastRow()).getValues().flat().forEach(id => {
    if (id != '') {
      sh2.getRange('B5').setValue(id)
      SpreadsheetApp.flush();
      savePDF()
    }
  })
}

function savePDF(){
  const folderID = '1N0AIh5oEszYw_NXKD0Vx1XrXUiPuUadR';
  const ss = SpreadsheetApp.getActiveSpreadsheet();
  const sh = ss.getSheetByName('Student Progress Report');      
  const d = Utilities.formatDate(new Date(), Session.getScriptTimeZone(), "yyyy-MM-dd")
  const filename = sh.getRange('B5').getValue() + '_' + d + ".pdf"
  const url = 'https://docs.google.com/spreadsheets/d/' + ss.getId() + '/export?';
  const exportOptions =
    'exportFormat=pdf&format=pdf' + 
    '&size=A4' + 
    '&portrait=true' +                     
    '&fitw=true' +                        
    '&sheetnames=false&printtitle=false' + 
    '&pagenumbers=false&gridlines=false' + 
    '&fzr=false' +
    '&gid=' + sh.getSheetId();
  var params = {method:"GET",headers:{"authorization":"Bearer "+ ScriptApp.getOAuthToken()}};
  var response = UrlFetchApp.fetch(url + exportOptions, params).getBlob();
  DriveApp.getFolderById(folderID).createFile(response.setName(filename));
}

Here is a draft

function saveAllAsPDF(){
  const ss = SpreadsheetApp.getActiveSpreadsheet();
  const sh1 = ss.getSheetByName('IMPORT Masterlist');       
  const sh2 = ss.getSheetByName('Student Progress Report');            
  sh1.getRange('A2:A'+sh1.getLastRow()).getValues().flat().forEach(id => {
    if (id != '') {
      sh2.getRange('B5').setValue(id)
      SpreadsheetApp.flush();
      savePDF()
    }
  })
}

function savePDF(){
  const folderID = '1N0AIh5oEszYw_NXKD0Vx1XrXUiPuUadR';
  const ss = SpreadsheetApp.getActiveSpreadsheet();
  const sh = ss.getSheetByName('Student Progress Report');      
  const d = Utilities.formatDate(new Date(), Session.getScriptTimeZone(), "yyyy-MM-dd")
  const filename = sh.getRange('B5').getValue() + '_' + d + ".pdf"
  const url = 'https://docs.google.com/spreadsheets/d/' + ss.getId() + '/export?';
  const exportOptions =
    'exportFormat=pdf&format=pdf' + 
    '&size=A4' + 
    '&portrait=true' +                     
    '&fitw=true' +                        
    '&sheetnames=false&printtitle=false' + 
    '&pagenumbers=false&gridlines=false' + 
    '&fzr=false' +
    '&gid=' + sh.getSheetId();
  var params = {method:"GET",headers:{"authorization":"Bearer "+ ScriptApp.getOAuthToken()}};
  var response = UrlFetchApp.fetch(url + exportOptions, params).getBlob();
  DriveApp.getFolderById(folderID).createFile(response.setName(filename));
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文