我在互联网上搜索了一个答案,但找不到答案。过去,我已经为excel写了一些非常基本的脚本,但是我现在使用的是Google表格,并且希望有一个按钮可以隐藏指定的行,然后将电子表格发布为PDF。
我目前有1个隐藏行的按钮和1个要发布的按钮,但我想将它们组合起来。
这就是我所拥有的。这两个脚本单独都能正常工作,但是当我运行下面的代码时,似乎只有第二个函数可以工作。
/* Hide rows */
function hideRows() {
SpreadsheetApp.getActiveSheet().hideRows(46,160)
}
/* Email Google Spreadsheet as PDF */
function emailGoogleSpreadsheetAsPDF() {
// Send the PDF of the spreadsheet to this email address
var email = "useremail@useremailcom";
// Get the currently active spreadsheet URL (link)
var ss = SpreadsheetApp.getActiveSpreadsheet();
// Subject of email message
var date = Utilities.formatDate(new Date(), "GMT", "yyyy-MM-dd");
var subject = "" + ss.getName()+ " - " + date ;
// Email Body can be HTML too
var body = "You can find attached the Daily Status Report";
var blob = DriveApp.getFileById(ss.getId()).getAs("application/pdf");
blob.setName(ss.getName() + ".pdf");
// If allowed to send emails, send the email with the PDF attachment
if (MailApp.getRemainingDailyQuota() > 0)
GmailApp.sendEmail(email, subject, body, {
htmlBody: body,
attachments:[blob]
});
}
注意:我还想隐藏调用脚本的按钮,我可以通过在脚本范围内包含包含按钮的行来做到这一点吗?