这就是我所拥有的
function clearRange() {
var AUTH_TOKEN = "Enter your OAuth_Token";
var url = "placeholder url";
var auth = "AuthSub token=\"" + AUTH_TOKEN + "\"";
var res = UrlFetchApp.fetch(url, {
headers: {
Authorization: auth
}
});
UrlFetchApp.getRequest("placeholder url");
var ui = SpreadsheetApp.getUi();
var response = ui.alert('Do you have a Gmail Account? (Choose "No" if you are not signed in.)', ui.ButtonSet.YES_NO);
if (response == ui.Button.YES) {
var attachments = [{
fileName: "Innevape Wholesale Order Form.xlsx",
content: res.getContent(),
mimeType: "application/vnd.ms-excel"
}];
MailApp.sendEmail("placeholder email", "Innevape Wholesale Order", "", {
attachments: attachments
});
var ui = SpreadsheetApp.getUi();
var sent = ui.alert("Email Sent!", ui.Button.OK);
} else {
showURL("placeholder url");
function showURL(href) {
var app = UiApp.createApplication().setHeight(35).setWidth(90);
app.setTitle("Thank You!");
var link = app.createAnchor("Download File", href).setId("link");
app.add(link);
var doc = SpreadsheetApp.getActive();
doc.show(app);
}
}
var sheet = SpreadsheetApp.getActive().getSheetByName('Mix Sheet');
sheet.getRange('B3:F29').clearContent();
}
代码附在我的电子表格上的一个按钮上,该按钮应打开一个框,询问他们是否有一个Gmail帐户。如果他们选择“是”,那么它应该发送电子邮件给我,并给他们一个确认窗口,上面写着“发送电子邮件!”。如果他们选择“否”,那么我希望它打开一个框来下载文件,以便他们可以自己发送电子邮件。毕竟,它应该清除指定的细胞。
如果您选择“否”,则说
“TypeError:showURL不是函数,它是未定义的。”
如果“是”,则会发送电子邮件,但说
“无法找到方法警报(字符串,按钮)。”
目前两种选择都没有清除细胞。