Retrieve rows from spreadsheet data using google app script

后端 未结 2 1484
有刺的猬
有刺的猬 2020-12-23 18:55

I am using Google app script to write form data to spreadsheet. Now I would like to fetch the values from Excel which matches conditions (eg., filtered by date, username) an

2条回答
  •  遥遥无期
    2020-12-23 19:18

    Well, you can consider use a cell and use the "Query" formula on it. Lets assume Date is at Column A, Username = Column B, Comment is Column C, while the blank cell is D1, your script will look like this:

    SpreadsheetApp.getActiveSheet().getRange("D1").setFormula('Query(A:C,"SELECT A,B,C WHERE B="' + "SomeOne'" + ',1)'; //filter the data and populate to D1 onwards    
    SpreadsheetApp.getActiveSheet().getRange("D:F").getValues();//this is the filtered data
    

提交回复
热议问题