I am trying to search row by column value in spreadsheet (Google Sheets) API Google documentation having API for find & Replace but no API available for find/search.
Some approaches i already tried to achieve searching by value in spreadsheet.
Google Visualization API Query Language: this approach is returning rows matching values.
Some issues in response:
a) Not returning row number (No indexing)
b) search is case sensitive
Is it possible to get row number in result of this method?
Set column
=ROW(INDIRECT(ADDRESS(MATCH("search_string",B:B,0),1)))
Got row number eg : 2
And then Get row by get value by range: https://sheets.googleapis.com/v4/spreadsheets/1Y65ZA5mhyImLL00yGR3lqwtbm6MgGLV0nV014fRXhts/values/A2:Z2
This is not a proper way for this i have to create a cell with Formula and then find the row by value in that cell and also clear sell after search done.
*This approach returns only one row.
DeveloperMetadataLookup: i don't know how to use this I created meta data on sheet with metadataKey : key1 metadataValue : value1
Searching by spreadsheets.values.batchGetByDataFilter
using dataFilter:DeveloperMetadataLookup{"metadataKey":"key1","metadataValue":"value1"}
This returning all rows in sheet i don't know how to find specific row with this method.
Google Apps Text Finder : i don't know if this is free to use with spreadsheet API.
Basic Filter: i read about this but don't know how to use it for searching.
Some old questions of same topic suggesting to fetch all rows and loop them to get row by value.
Example: this will hang my server i don't want implement this loop.
function find(value, range) {
var data = range.getValues();
for (var i = 0; i < data.length; i++) {
for (var j = 0; j < data[i].length; j++) {
if (data[i][j] == value) {
return range.getCell(i + 1, j + 1);
}
}
}
return null;
}
Conclusion:
Can anyone help me to make a proper way to searching a row by column value in sheets ?
Is it possible to search row by column value with (DeveloperMetadataLookup or Basic Filter) If yes then please suggest me proper way to use it.
Google Visualization API Query Language : is it possible to get row number ?
This is a example sheet
Column-> A, B, C
Row1->B-15, planY, 50
Row2->B-18, planZ, 80
Row3->B-19, planC, 70
Row4->B-21, planZ, 90
My requirement search column:B = value:planZ | (B=planZ)
Result should be similar to this :
Row:{
"2":["B-18","planZ","80"],
"4":["B-21","planZ","90"]
}