Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Email 如何使用脚本将google电子表格复制到gmail?_Email_Google Apps Script_Google Sheets_Html Table - Fatal编程技术网

Email 如何使用脚本将google电子表格复制到gmail?

Email 如何使用脚本将google电子表格复制到gmail?,email,google-apps-script,google-sheets,html-table,Email,Google Apps Script,Google Sheets,Html Table,嗨,我正在尝试使用脚本将一定范围的单元格从google sheet复制到gmail。但它不起作用,尤其是格式正在改变。如何使用脚本像“ctrl+c->ctrl+v”一样复制?这是我的密码 function myFunction() { var sheet = SpreadsheetApp.getActiveSpreadsheet(); //access to the spreadsheet SpreadsheetApp.setActiveSheet(sheet.getSheetByNam

嗨,我正在尝试使用脚本将一定范围的单元格从google sheet复制到gmail。但它不起作用,尤其是格式正在改变。如何使用脚本像“ctrl+c->ctrl+v”一样复制?这是我的密码

function myFunction() {
  var sheet = SpreadsheetApp.getActiveSpreadsheet(); //access to the spreadsheet
  SpreadsheetApp.setActiveSheet(sheet.getSheetByName('MAIL')); //access to the sheet by name
  var range = sheet.getRange('C7:I23'); //assign the range you want to copy
  var copy = range.getValues();
  var sh = SpreadsheetApp.getActiveSpreadsheet();
  SpreadsheetApp.setActiveSheet(sh.getSheetByName('MAIL'));
  var data = sh.getRange("C7:I23").getValues();
  var htmltable =[];

  //var TABLEFORMAT-> // i want this format just like i made on spread sheet
  //var htmltable = '<table ' +TABLEFORMAT+' ">';

  for (row = 0; row<data.length; row++){
    htmltable += '<tr>';
    for (col = 0 ;col<data[row].length; col++){
      if (data[row][col] === "" || 0) {
        htmltable += '<td>' + ' ' +'</td>';
      } 
      else if (row === 0)  {
        htmltable += '<th>' + data[row][col] + '</th>';
      }
      else {
        htmltable += '<td>' + data[row][col] + '</td>';
      }
    }
    htmltable += '</tr>';
  }
  htmltable += '</table>';
  Logger.log(data);
  Logger.log(htmltable);
  var email_subject = "";
  var my_email = "mail";
  MailApp.sendEmail({
    to: my_email,
    subject: email_subject,
    htmlBody: htmltable, 
  })}
函数myFunction(){
var sheet=SpreadsheetApp.getActiveSpreadsheet();//访问电子表格
SpreadsheetApp.setActiveSheet(sheet.getSheetByName('MAIL');//按名称访问工作表
var range=sheet.getRange('C7:I23');//指定要复制的范围
var copy=range.getValues();
var sh=SpreadsheetApp.getActiveSpreadsheet();
电子表格app.setActiveSheet(sh.getSheetByName('MAIL');
var data=sh.getRange(“C7:I23”).getValues();
var htmltable=[];
//var TABLEFORMAT->//我想要这个格式,就像我在电子表格上做的一样

//var htmltable='我认为,当您提供一个包含输入值和所需样本输出的样本电子表格时,它将帮助用户思考您的问题和解决方案。当然,请删除您的个人信息。您能解释一下更改的格式吗?可能是屏幕快照我想知道表格的格式..什么时候我发送电子邮件的表格格式和邮件格式是不同的。像颜色线的样式。值是一样的。