简体   繁体   中英

getSheetValues not returning data Google Script

The log for my script returns no information. I've copy-pasted this script with minimal changes from this stack overflow thread . I confirmed the content from the thread in from the relevant google scripts manual . Can someone shine some light on this problem?

  function myFunction() 
  {
    function stripArray(values) 
    {
      return values.filter(function(d) 
      {
        return d.length && d[0] !== '';
      });
    }

   function testSheet()
    {
      var ssId="1kRdKGDQJXxCW2q1HPclWcpsOpI1BJPvAlMjvLSX6JvY";
      var ss = SpreadsheetApp.openById(ssId);
      var sheet = ss.getSheetByName("Sheet1");
      var values = sheet.getSheetValues(3, 2, 21, 23);
      Logger.log(values);
      Logger.log(stripArray(values));

    }

  }

Thanks

The functions stripArray(values) and testSheet() should be seperate functions. Try This code below:

function stripArray(values) 
{
   return values.filter(function(d) 
   {
      return d.length && d[0] !== '';
   });
}

function testSheet()
    {
      var ssId="1kRdKGDQJXxCW2q1HPclWcpsOpI1BJPvAlMjvLSX6JvY";
      var ss = SpreadsheetApp.openById(ssId);
      var sheet = ss.getSheetByName("Announcements");
      var values = sheet.getSheetValues(3, 2, 21, 23);
      Logger.log(values);
   Logger.log(stripArray(values));

    }

Hope that helps!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM