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

问题描述

目标:从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({
[email protected]
主题:图表,
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: "[email protected]",
    subject: "Chart",
    htmlBody: "Chart! <br> <img src='cid:chartImg'> ! <br> Wow",
    inlineImages: {
        chartImg: chartImage,
    }
  });
}

I hope it helps =)

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

10-28 08:30