开发者

How to ignore empty cell values in column

I have a script that import range in files from folder. The promblem is that in column A i have 3000 not emty cell, but i need import all range but filter that have not empty cell in column B

function Import_() {
  var arr = [];
  var files = DriveApp.getFolderById("17Ux9i0mK_RTuLbrjFrZDGoNl3AkcEdRS").getFiles();

  var ss = SpreadsheetApp.getActiveSpreadsheet()
  var copyS开发者_Python百科heet = ss.getSheetByName("Cell")
  copySheet.getRange('A2:M').clear();

  while (files.hasNext()) {
    var file = files.next();

    var ss1 = SpreadsheetApp.openById(file.getId())
    var sheets = ss1.getSheetByName("Cell")
    var sheetsRange = sheets.getDataRange()
    var sheetsValues = sheetsRange.getValues()
    
    arr = arr.concat(sheetsValues.slice(4))
  }

copySheet.getRange(2, 1, arr.length, arr[0].length).setValues(arr)


try this:

function Import_() {
  var arr = [];
  var files = DriveApp.getFolderById("17Ux9i0mK_RTuLbrjFrZDGoNl3AkcEdRS").getFiles();
  var ss = SpreadsheetApp.getActive\()
  var sh = ss.getSheetByName("Cell")
  sh.getRange('A2:M' + sh.getLastRow()).clear();
  while (files.hasNext()) {
    var file = files.next();
    var ss1 = SpreadsheetApp.openById(file.getId())
    var s = ss1.getSheetByName("Cell")
    var v = s.getDataRange().getValues().filter(r => r[1]).filter(e => e);
    arr = arr.concat(v.slice(4))
  }
  sh.getRange(2, 1, arr.length, arr[0].length).setValues(arr)
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜