Is it possible to create a single pdf from multiple Google spreadsheets?

旧街凉风 提交于 2020-12-13 11:54:28

问题


I am able to create a pdf from a single Google spreadsheet sheet using this code.

Is it possible to tweak this code to allow multiple sheets from different spreadsheets to be merged into a single pdf? Or would I need to take an entirely different approach?


回答1:


I guess you can't but you can easily merge spreadsheets into a temporary spreadsheet and export this one as pdf.

to merge sheets from different origins you have a choice of methods to choose from, below is a small example that gets 1 sheet from the active SS and one from another SS and merge it in a "temp" SS.

The destination spreadsheet will have 3 sheets :

  • sheet1
  • copy of sheet1
  • copy of sheet1 1

You'll just have to clean it up and rename to your needs.

code :

function mergeSS(){
  var dest = SpreadsheetApp.create('temp');
  var s1 = SpreadsheetApp.getActive().getSheets()[0];// one opening method
  var s2 = SpreadsheetApp.openById('1NmeLtT4_9jRzau__________o23KG8hYdJj6w').getSheets()[0];// another opening method
  s1.copyTo(dest);
  s2.copyTo(dest);
}


来源:https://stackoverflow.com/questions/25515853/is-it-possible-to-create-a-single-pdf-from-multiple-google-spreadsheets

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!