如何将从电子表格中提取的内嵌图表添加到电子邮件中? [英] How add an inline chart pulled from a spreadsheet into an email?

查看:93
本文介绍了如何将从电子表格中提取的内嵌图表添加到电子邮件中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目标:从Google Spreadsheet中获取现有图表,将内联添加到电子邮件中并发送。我相信GetChart类可能会有所帮助,但无法弄清楚。

解决方案

您可以将图表显示为图片嵌入到邮件中



简单示例

  function sendChart(){
var dataTable = SpreadsheetApp.getActiveSpreadsheet()
.getDataRange()
.getDataTable(true);

var chartImage = Charts.newPieChart()
.setTitle('Title')
.setDataTable(dataTable)
.build()
.getAs ( '图像/ JPEG'); //将图表作为图片

MailApp.sendEmail({
:example@example.com,
主题:图表,
htmlBody:图表< br>< img src ='cid:chartImg'>!< br> Wow,
inlineImages:{
chartImg:chartImage,
}
});
}

我希望它有帮助=)


Goal: take an existing chart from a Google Spreadsheet, add inline to an email and send. I believe the GetChart class may help, but cannot figure out how.

解决方案

You can get chart as image and embed it to message

Simple example

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,
    }
  });
}

I hope it helps =)

这篇关于如何将从电子表格中提取的内嵌图表添加到电子邮件中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆