嗨,我有这个脚本,我用它来将一组工作表作为 PDF 通过电子邮件发送,它工作正常,除了边距我需要能够将边距设置为 顶部为 0.5 侧面 0.25 和 底部为 0.6 这是我现有的脚本
function createPDF() {
var mainSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Main');
var sheetNames = mainSheet.getRange('B3:B').getValues().flat().filter(String);
var selectedSheets = sheetNames.filter(function(name, i) {
return mainSheet.getRange(i+3, 1).getValue();
});
var sheetsToHide = [mainSheet];
SpreadsheetApp.getActiveSpreadsheet().getSheets().forEach(function(sheet) {
if (sheet.getName() !== 'Main' && sheet.getName() !== 'Template' && sheet.getName() !== 'Import' && selectedSheets.indexOf(sheet.getName()) === -1) {
sheetsToHide.push(sheet);
}
});
sheetsToHide.forEach(function(sheet) {
sheet.hideSheet();
});
var blob = mainSheet.getParent().getAs('application/pdf');
var file = DriveApp.createFile(blob).setName('PDF Report');
GmailApp.sendEmail(Session.getActiveUser().getEmail(), "PDF Report", "", {attachments:[file]});
file.setTrashed(true);
sheetsToHide.forEach(function(sheet) {
sheet.showSheet();
});
updateCheckboxes();
}
谢谢