以表格形式从Google工作表发送电子邮件,而无需使用工作表转换器 [英] Send Email from Google sheet as a table without using sheets convertor

查看:62
本文介绍了以表格形式从Google工作表发送电子邮件,而无需使用工作表转换器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请检查以下电子表格:电子表格

Please check the spreadsheet below: spreadsheet

https://docs.google.com/spreadsheets/d/1QFPO4bQfYPM4rRJ_6PYxUrYsFgVeUFx89_nZ1mNaLew/edit#gid = 0

由于我在这里看到过这些帖子,因此我当前正在使用的脚本可以正常工作.我只是想以更好的方式发送它.我已经检查了其他帖子,甚至看到了SheetConverter,但对我来说太复杂了.

The script that I'm currently using is working fine thanks to the posts I've seen here. I just wanted to send it in a better way. I've already checked other posts and I even saw the SheetConverter but is too complicated for me.

当前结果: https://drive.google.com/file/d/1-OQqnsRwIJaoXOnYZEtPxHy6r3buB8H7/view?usp = sharing

请检查图像以获取所需的结果.谢谢! https://drive.google.com/file/d/1p7cJBTyaZ1ZqI5Jv5WWOGg6_Q-JegfHj/view?usp = sharing

Please check image for the desired result. Thanks! https://drive.google.com/file/d/1p7cJBTyaZ1ZqI5Jv5WWOGg6_Q-JegfHj/view?usp=sharing

推荐答案

您可以创建一个html表,如下所示:

You can create an html table, like this:

    function sendEmail(data){

     MailApp.sendEmail({
        to: "example@mail.com",
        subject: "Example",
        htmlBody:"<html><body>" + createTable(data)+ "</body></html>"});

    }

    function createTable(data){
        var cells = [];

        var table = "<html><body><br><table border=1><tr><th>Start Date</th><th>End Date</th><th>Leave dates</th><th>Status</th></tr>";

        for (var i = 0; i < data.length; i++){
            cells = data[i].toString().split(",");
            table = table + "<tr></tr>";

            for (var u = 0; u < cells.length; u++){
                table = table + "<td>"+ cells[u] +"</td>";
            }
        }

        table=table+"</table></body></html>";
        return table;
    }

假设您已经将数据保存在2D数组中(行和列的值).

Supposing you already have the data in a 2D array (rows and columns values).

这篇关于以表格形式从Google工作表发送电子邮件,而无需使用工作表转换器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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