简体   繁体   English

如何使用sheets.AppendRow? 我一直在所有单元格中收到错误 [Ljava.lang.Object;@29080d11

[英]How do I use sheets.AppendRow? I keep receiving an error [Ljava.lang.Object;@29080d11 in all the cells

I am retrieving the body of a email and inserting into google sheets.我正在检索电子邮件的正文并插入到 Google 表格中。 Keep getting [Ljava.lang.Object;@29080d11 errors.不断收到 [Ljava.lang.Object;@29080d11 错误。 I already have retrieveing the data working well.我已经检索了运行良好的数据。 I have a little problem with building the array to append to google sheets.我在构建数组以附加到谷歌表格时遇到了一些问题。 This is my code;这是我的代码;

function processInboxToSheet() {
  // var label = GmailApp.getUserLabelByName("NEWNOPS");
  var label = 'Inbox';
  var threads = GmailApp.search('subject:"New Quality Test Results"');
  // var threads = label.getThreads();
  // Set destination sheet
  var sheet = SpreadsheetApp.getActiveSheet();
  // Get all emails with subject  
  for (var i = 0; i < threads.length; i++) {
      var tmp;
      message = threads[i].getMessages()[0];  // second message in thread
      content = message.getPlainBody();  // remove html markup

      // next three lines cleans the message to just the data

      content = content.substr(content.search("Tank 1"));  // remove beginning of trash 
      var n = content.lastIndexOf("INH");
      content = content.substr(0,(n+14)); // get the body of the wanted data 
      //Logger.log(n);
      content = content.split("\n"); // create array based on newline    
     var data = [];
                  data.push(content[0].match(/[0-9]{2}[\/][0-9]{2}[\/][0-9]{4}/)); //Date
                  data.push(content[1].match("")); //Blank  /\d*\.\d{2}/
                  data.push(content[2].match(/\d*\.?\d{2}/)); //Bfat
                  data.push(content[3].match(/\d*\.\d{2}/)); //Prot
                  data.push(content[4].match(/\d*\.\d{2}/)); //Lact
                  data.push(content[5].match(/\d*\.\d{2}/)); //OS
                  data.push(content[6].match(/\d*,\d{3}/)); //SPC
                  data.push(content[7].match(/\d*\,\d{3}/)); //SCC
                  data.push(content[8].match(/\d{2}/)); //MUN
                  data.push(content[9].match(/-\d.\d{4}/)); //FRZ
                  data.push(content[10].match(/\d{2}/)); //TMP
                  data.push(content[11].match(/\d/)); //INH

        Logger.log(data);      
    if (content) {
     sheet.appendRow(data);
      // if no match); display error
    } // End if

  } // End for loop
};

my data;我的数据;

  Producer       32698-1          Date Of Notice     02/04/2020

       Cow Milker3

      8831 CHAPEL RD
       EASTERN, MD  21664




 Tank 1    Sample Date   02/03/2020   B O

 Bfat      4.09
 Prot      3.11
 Lact     4.720
 OS        5.64
 SPC      1,000
 SCC    100,000
 MUN         12
 FRZ    -0.5420
 TMP         37
 INH          0

The problem is that match returns an Array or null , so data is an "Array of Arrays" (multidimensional Array) but appendRow requires a "simple" Array.问题是match返回一个Arraynull ,所以data是一个“数组数组”(多维数组),但appendRow需要一个“简单”数组。

Unfortunately there isn't a "simple fix" (like adding one code line or few characters).不幸的是,没有“简单的修复”(例如添加一行代码或几个字符)。 You should rethink the logic of your script to handle the case that there match returns null because it's not a valid value to be passed to Google Sheets.您应该重新考虑脚本的逻辑来处理匹配返回null的情况,因为它不是传递给 Google 表格的有效值。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 appendRow 返回 [Ljava.lang.Object;@ 而不是值 - appendRow returns [Ljava.lang.Object;@ instead of values 在 Apps 脚本中接收 [Ljava.lang.Object(将附件名称从 Gmail 带到表格) - Receiving [Ljava.lang.Object in Apps Script (bringing attachment name from Gmail to Sheets) Google Sheet 导入 Ljava.lang.Object 错误 - Google Sheet Import Ljava.lang.Object error “[Ljava.lang.Object;@”是什么意思? - What does "[Ljava.lang.Object;@" mean? 消息说 [Ljava.lang.Object] 被传递代替值 - Message saying [Ljava.lang.Object] being delivered in place of values 我如何在 Internet Explorer 11 中使用 object.assign - How do i use object.assign in internet explorer 11 如何将多行单元格拆分为Google表格的数组? - How do I split multiline cells into arrays for Google Sheets? JDBC 错误:AbstractMethodError:com.microsoft.sqlserver.jdbc.SQLServerConnection.createArrayOf(Ljava/lang/String;[Ljava/lang/Object;)Ljava/sql/Array - JDBC ERROR : AbstractMethodError: com.microsoft.sqlserver.jdbc.SQLServerConnection.createArrayOf(Ljava/lang/String;[Ljava/lang/Object;)Ljava/sql/Array 我不断收到Uncaught TypeError:函数调用期间对象[object global]没有方法错误 - I keep receiving Uncaught TypeError: Object [object global] has no method error during function call 在编写公式后,我在粘贴数据的所有单元格中不断收到 REF 错误 - I'm keep getting REF error in all the cells that I paste the data to after writing the formula
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM