目标:从Google电子表格中获取现有图表,将内联添加到电子邮件中并发送。我相信GetChart类可能有所帮助,但无法弄清楚如何。
答案 0 :(得分:4)
您可以get chart as image和embed it to message
简单的例子
function sendChart(){
var dataTable = SpreadsheetApp.getActiveSpreadsheet()
.getDataRange()
.getDataTable(true);
var chartImage = Charts.newPieChart()
.setTitle('Title')
.setDataTable(dataTable)
.build()
.getAs('image/jpeg'); //get chart as image
MailApp.sendEmail({
to: "example@example.com",
subject: "Chart",
htmlBody: "Chart! <br> <img src='cid:chartImg'> ! <br> Wow",
inlineImages: {
chartImg: chartImage,
}
});
}
我希望它有帮助=)