Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/google-sheets/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
Google apps script 当.appendText()时,如何解决此问题;无法插入空文本元素";_Google Apps Script_Google Sheets_Google Docs - Fatal编程技术网

Google apps script 当.appendText()时,如何解决此问题;无法插入空文本元素";

Google apps script 当.appendText()时,如何解决此问题;无法插入空文本元素";,google-apps-script,google-sheets,google-docs,Google Apps Script,Google Sheets,Google Docs,我创建了这个函数,它从google sheet列中获取a值,并将其作为文本和二维码附加到google Docs文档中 但是我不断地得到这个错误(不能插入一个空的文本元素。(第54行,文件“代码”)忽略),即使我得到了目标文档中显示的文本和或代码。 我假设它与最后填充的行之后没有值的行有关。 在我的for循环中有什么我可以做的吗 function createQRCodeFromColumnList() { var ss = SpreadsheetApp.openById('sdf

我创建了这个函数,它从google sheet列中获取a值,并将其作为文本和二维码附加到google Docs文档中

但是我不断地得到这个错误(不能插入一个空的文本元素。(第54行,文件“代码”)忽略),即使我得到了目标文档中显示的文本和或代码。 我假设它与最后填充的行之后没有值的行有关。 在我的for循环中有什么我可以做的吗

  function createQRCodeFromColumnList() {

     var ss = SpreadsheetApp.openById('sdfsdfsdfsdfsdfsd')// source ID
     var sourceSheet = ss.getSheetByName('LISTS');// my source sheet
     var lastRow = ss.getLastRow();
     var sourceData = sourceSheet.getRange(3,1,lastRow -1,1).getValues();// the row with the values 
     to become OR codes and references 
      Logger.log(sourceData);

     //target doc
     var targetDoc = DocumentApp.openById('3fgsdfgfgdfgdfgdfgdfgdfg44');// 
     destination Doc
     var body = targetDoc.getBody();

      for (var i = 0; i < sourceData.length; i++) {
      var sourceId = sourceData[i][0];

      var url = "https://chart.googleapis.com/chart?chs=150x150&cht=qr&chl=" + sourceId

      var resp = UrlFetchApp.fetch(url); // Get the image of QR code
      body.getChild(0).asParagraph().appendText(sourceId);// QR Code referencence number
      body.getChild(0).asParagraph().appendInlineImage(resp.getBlob());// OR code
      } 
函数createQRCodeFromColumnList(){
var ss=SpreadsheetApp.openById('sdfsdfsd')//源ID
var sourceSheet=ss.getSheetByName('LISTS');//我的源代码表
var lastRow=ss.getLastRow();
var sourceData=sourceSheet.getRange(3,1,lastRow-1,1).getValues();//包含值的行
成为或成为代码和参考
Logger.log(sourceData);
//目标文件
var targetDoc=DocumentApp.openById('3fgsdffgdfgdfgdfgdfgfg44');//
目的地单据
var body=targetDoc.getBody();
对于(var i=0;i

This
sourceSheet.getRange(3,1,lastRow-1,1).getValues();
应该是This
sourceSheet.getRange(3,1,lastRow-2,1).getValues();
也许还有这个:
for(var i=0;i
  • [google sheets]相关文章推荐