function convertSpreadsheetToPdfNonIncremental(spreadsheetId, sheetName, pdfName) {
var spreadsheet = spreadsheetId ? SpreadsheetApp.openById(spreadsheetId) : SpreadsheetApp.getActiveSpreadsheet();
spreadsheetId = spreadsheetId ? spreadsheetId : spreadsheet.getId()
var sheetId = sheetName ? spreadsheet.getSheetByName(sheetName).getSheetId() : null;
var pdfName = pdfName ? pdfName : spreadsheet.getName();
var parents = DriveApp.getFileById(spreadsheetId).getParents();
var folder = parents.hasNext() ? parents.next() : DriveApp.getRootFolder();
var url_base = spreadsheet.getUrl().replace(/edit$/,'');
var url_ext = 'export?exportFormat=pdf&format=pdf' //export as pdf
// Print either the entire Spreadsheet or the specified sheet if optSheetId is provided
+ (sheetId ? ('&gid=' + sheetId) : ('&id=' + spreadsheetId))
+ '&gid=1012506648'
+ '&id=11NMFpk15pZ12RdXUsFRN8onueG9mhZqV57xLz_YoQY8'
// following parameters are optional...
+ '&size=letter' // paper size
+ '&portrait=false' // orientation, false for landscape
+ '&scale=4' //1= Normal 100% / 2= Fit to width / 3= Fit to height / 4= Fit to Page
+ '&sheetnames=false&printtitle=false&pagenumbers=false' //hide optional headers and footers
+ '&gridlines=false' // hide gridlines
+ '&fzr=false'; // do not repeat row headers (frozen rows) on each page
var options = {
headers: {
'Authorization': 'Bearer ' + ScriptApp.getOAuthToken(),
}
}
var response = UrlFetchApp.fetch(url_base + url_ext, options);
var file=DriveApp.getFileById('11NMFpk15pZ12RdXUsFRN8onueG9mhZqV57xLz_YoQY8');
var range = SpreadsheetApp.getActive().getRange('B3:C7');
var first = range.getCell(1, 1);
var last = range.getCell(5,2);
var pdfName = first.getValue() + ' Timesheet for Payroll Beginning ' + last.getDisplayValue();
var blob = response.getBlob().setName(pdfName +'.pdf');
folder.createFile(blob);
}
function convertSpreadsheetToPdfIncremental(spreadsheetId, sheetName, pdfName) {
var spreadsheet = spreadsheetId ? SpreadsheetApp.openById(spreadsheetId) : SpreadsheetApp.getActiveSpreadsheet();
spreadsheetId = spreadsheetId ? spreadsheetId : spreadsheet.getId()
var sheetId = sheetName ? spreadsheet.getSheetByName(sheetName).getSheetId() : null;
var pdfName = pdfName ? pdfName : spreadsheet.getName();
var parents = DriveApp.getFileById(spreadsheetId).getParents();
var folder = parents.hasNext() ? parents.next() : DriveApp.getRootFolder();
var url_base = spreadsheet.getUrl().replace(/edit$/,'');
var url_ext = 'export?exportFormat=pdf&format=pdf' //export as pdf
// Print either the entire Spreadsheet or the specified sheet if optSheetId1 is provided
+ (sheetId ? ('&gid=' + sheetId) : ('&id=' + spreadsheetId))
// following parameters are optional...
+ '&size=letter' // paper size
+ '&portrait=false' // orientation, false for landscape
+ '&scale=4' //1= Normal 100% / 2= Fit to width / 3= Fit to height / 4= Fit to Page
+ '&sheetnames=false&printtitle=false&pagenumbers=false' //hide optional headers and footers
+ '&gridlines=false' // hide gridlines
+ '&fzr=false'; // do not repeat row headers (frozen rows) on each page
var options = {
headers: {
'Authorization': 'Bearer ' + ScriptApp.getOAuthToken(),
}
}
var response = UrlFetchApp.fetch(url_base + url_ext, options);
var file=DriveApp.getFileById('11NMFpk15pZ12RdXUsFRN8onueG9mhZqV57xLz_YoQY8');
var range = SpreadsheetApp.getActive().getRange('B3:C7');
var first = range.getCell(1, 1);
var last = range.getCell(5,2);
var pdfName = first.getValue() + ' Timesheet for Payroll Beginning ' + last.getDisplayValue();
var blob = response.getBlob().setName(pdfName +'.pdf');
folder.createFile(blob);
}

我找到了,并且能够找出脚本,将一个工作簿或所有工作簿转换为PDF但无法找到有关如何在转换时转换多个但不是全部或排除工作簿的指令/提示到PDF。
我有一个Google表格电子表格,我希望通过脚本将所有工作簿转换成PDF格式,并且不能隐藏我不想转换的工作簿。
请帮忙!