本文介绍了Google脚本:如何通过电子邮件发送Tablechart?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在用Google Script创建一个表格,我想通过电子邮件发送它.
I'm creating a tablechart in Google Script and I want to send this through e-mail.
这是我的代码
var data = Charts.newDataTable()
.addColumn(Charts.ColumnType.STRING, 'Month')
.addColumn(Charts.ColumnType.NUMBER, 'In Store')
.addColumn(Charts.ColumnType.NUMBER, 'Online')
.addRow(['January', 10, 1])
.addRow(['February', 12, 1])
.addRow(['March', 20, 2])
.addRow(['April', 25, 3])
.addRow(['May', 30, 4])
.build();
var chart = Charts.newTableChart()
.setDataTable(data)
.enableSorting(true)
.build();
MailApp.sendEmail({
to: "[email protected]",
subject: "Test",
htmlBody: "inline Google Logo<img src='cid:inImage'> images! <br>",
inlineImages:
{
inImage: chart.getBlob().setContentType('image/png'),
}
});
代码在 chart.getBlob().setContentType('image/png')
上给出以下错误消息:
The code gives the following error message on chart.getBlob().setContentType('image/png')
:
有人知道怎么了吗?
谢谢!
推荐答案
此修改如何?
var chart = Charts.newTableChart()
.setDataTable(data)
.enableSorting(true)
.build();
收件人:
var chart = Charts.newTableChart()
.setDataTable(data)
.enableSorting(true)
.setDimensions(640, 480) // Added
.build();
它使用 setDimensions()
设置图表的大小.
It sets the size of chart using setDimensions()
.
- 您还可以使用
chart.getAs('image/png')
代替chart.getBlob().setContentType('image/png')
. li>
- Also you can use
chart.getAs('image/png')
instead ofchart.getBlob().setContentType('image/png')
.
如果这不是您想要的,请告诉我.我想修改它.
If this was not what you want, please tell me. I would like to modify it.
这篇关于Google脚本:如何通过电子邮件发送Tablechart?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!