Использование TextFinder для поиска посла
Это все местоположения, в которых есть «Посол» в вашей электронной таблице, используя textfinder .Поиск был очень быстрым.
Sheet: Crew_Traits Cell: D1 Row: 1 Col: 4 Value: Ambassador
Sheet: Crew_Traits Cell: D13 Row: 13 Col: 4 Value: Ambassador
Sheet: Crew_Traits Cell: A30 Row: 30 Col: 1 Value: Ambassador Fox
Sheet: Crew_Traits Cell: A31 Row: 31 Col: 1 Value: Ambassador K'Ehleyr
Sheet: Crew_Traits Cell: D31 Row: 31 Col: 4 Value: Ambassador
Sheet: Crew_Traits Cell: A32 Row: 32 Col: 1 Value: Ambassador Neelix
Sheet: Crew_Traits Cell: D32 Row: 32 Col: 4 Value: Ambassador
Sheet: Crew_Traits Cell: A33 Row: 33 Col: 1 Value: Ambassador Sarek
Sheet: Crew_Traits Cell: A34 Row: 34 Col: 1 Value: Ambassador Shras
Sheet: Crew_Traits Cell: D34 Row: 34 Col: 4 Value: Ambassador
Sheet: Crew_Traits Cell: A35 Row: 35 Col: 1 Value: Ambassador Soval
Sheet: Crew_Traits Cell: A36 Row: 36 Col: 1 Value: Ambassador Spock
Sheet: Crew_Traits Cell: A37 Row: 37 Col: 1 Value: Ambassador Troi
Sheet: 1* Cell: A31 Row: 31 Col: 1 Value: Ambassador Fox
Sheet: 1* Cell: A32 Row: 32 Col: 1 Value: Ambassador K'Ehleyr
Sheet: 1* Cell: A33 Row: 33 Col: 1 Value: Ambassador Neelix
Sheet: 1* Cell: A34 Row: 34 Col: 1 Value: Ambassador Sarek
Sheet: 1* Cell: A35 Row: 35 Col: 1 Value: Ambassador Shras
Sheet: 1* Cell: A36 Row: 36 Col: 1 Value: Ambassador Soval
Sheet: 1* Cell: A37 Row: 37 Col: 1 Value: Ambassador Spock
Sheet: 1* Cell: A38 Row: 38 Col: 1 Value: Ambassador Troi
Sheet: 2* Cell: A31 Row: 31 Col: 1 Value: Ambassador Fox
Sheet: 2* Cell: A32 Row: 32 Col: 1 Value: Ambassador K'Ehleyr
Sheet: 2* Cell: A33 Row: 33 Col: 1 Value: Ambassador Neelix
Sheet: 2* Cell: A34 Row: 34 Col: 1 Value: Ambassador Sarek
Sheet: 2* Cell: A35 Row: 35 Col: 1 Value: Ambassador Shras
Sheet: 2* Cell: A36 Row: 36 Col: 1 Value: Ambassador Soval
Sheet: 2* Cell: A37 Row: 37 Col: 1 Value: Ambassador Spock
Sheet: 2* Cell: A38 Row: 38 Col: 1 Value: Ambassador Troi
Sheet: 3* Cell: A30 Row: 30 Col: 1 Value: Ambassador Fox
Sheet: 3* Cell: A31 Row: 31 Col: 1 Value: Ambassador K'Ehleyr
Sheet: 3* Cell: A32 Row: 32 Col: 1 Value: Ambassador Neelix
Sheet: 3* Cell: A33 Row: 33 Col: 1 Value: Ambassador Sarek
Sheet: 3* Cell: A34 Row: 34 Col: 1 Value: Ambassador Shras
Sheet: 3* Cell: A35 Row: 35 Col: 1 Value: Ambassador Soval
Sheet: 3* Cell: A36 Row: 36 Col: 1 Value: Ambassador Spock
Sheet: 3* Cell: A37 Row: 37 Col: 1 Value: Ambassador Troi
Sheet: 4* Cell: A29 Row: 29 Col: 1 Value: Ambassador K'Ehleyr
Sheet: 4* Cell: A30 Row: 30 Col: 1 Value: Ambassador Sarek
Sheet: 4* Cell: A31 Row: 31 Col: 1 Value: Ambassador Shras
Sheet: 4* Cell: A32 Row: 32 Col: 1 Value: Ambassador Soval
Sheet: 4* Cell: A33 Row: 33 Col: 1 Value: Ambassador Spock
Sheet: 4* Cell: A34 Row: 34 Col: 1 Value: Ambassador Troi
Sheet: 5* Cell: A19 Row: 19 Col: 1 Value: Ambassador Soval
Sheet: 5* Cell: A20 Row: 20 Col: 1 Value: Ambassador Troi
Sheet: Crew_URLs Cell: A31 Row: 31 Col: 1 Value: Ambassador Fox
Sheet: Crew_URLs Cell: B31 Row: 31 Col: 2 Value: /wiki/Ambassador_Fox
Sheet: Crew_URLs Cell: A32 Row: 32 Col: 1 Value: Ambassador K'Ehleyr
Sheet: Crew_URLs Cell: B32 Row: 32 Col: 2 Value: /wiki/Ambassador_K%27Ehleyr
Sheet: Crew_URLs Cell: A33 Row: 33 Col: 1 Value: Ambassador Neelix
Sheet: Crew_URLs Cell: B33 Row: 33 Col: 2 Value: /wiki/Ambassador_Neelix
Sheet: Crew_URLs Cell: A34 Row: 34 Col: 1 Value: Ambassador Sarek
Sheet: Crew_URLs Cell: B34 Row: 34 Col: 2 Value: /wiki/Ambassador_Sarek
Sheet: Crew_URLs Cell: A35 Row: 35 Col: 1 Value: Ambassador Shras
Sheet: Crew_URLs Cell: B35 Row: 35 Col: 2 Value: /wiki/Ambassador_Shras
Sheet: Crew_URLs Cell: A36 Row: 36 Col: 1 Value: Ambassador Soval
Sheet: Crew_URLs Cell: B36 Row: 36 Col: 2 Value: /wiki/Ambassador_Soval
Sheet: Crew_URLs Cell: A37 Row: 37 Col: 1 Value: Ambassador Spock
Sheet: Crew_URLs Cell: B37 Row: 37 Col: 2 Value: /wiki/Ambassador_Spock
Sheet: Crew_URLs Cell: A38 Row: 38 Col: 1 Value: Ambassador Troi
Sheet: Crew_URLs Cell: B38 Row: 38 Col: 2 Value: /wiki/Ambassador_Troi
Sheet: Crew_Basics Cell: A31 Row: 31 Col: 1 Value: Ambassador Fox
Sheet: Crew_Basics Cell: A32 Row: 32 Col: 1 Value: Ambassador K'Ehleyr
Sheet: Crew_Basics Cell: A33 Row: 33 Col: 1 Value: Ambassador Neelix
Sheet: Crew_Basics Cell: A34 Row: 34 Col: 1 Value: Ambassador Sarek
Sheet: Crew_Basics Cell: A35 Row: 35 Col: 1 Value: Ambassador Shras
Sheet: Crew_Basics Cell: A36 Row: 36 Col: 1 Value: Ambassador Soval
Sheet: Crew_Basics Cell: A37 Row: 37 Col: 1 Value: Ambassador Spock
Sheet: Crew_Basics Cell: A38 Row: 38 Col: 1 Value: Ambassador Troi
Вот код: sObj.ssid - это идентификатор вашей электронной таблицы.1010 *
function regexSearch(sObj) {
var ss=SpreadsheetApp.openById(sObj.ssid);
var tf=ss.createTextFinder(sObj.pattern).useRegularExpression(true);
var all=tf.findAll();
var matches='';
for(var i=0;i<all.length;i++) {
matches+=Utilities.formatString('Sheet: %s Cell: %s Row: %s Col: %s Value: %s\n',all[i].getSheet().getName(),all[i].getA1Notation(),all[i].getRow(),all[i].getColumn(),all[i].getValue());
}
if(matches) {
sObj.matches=matches;
}else{
sObj.message(Utilities.formatString('No Matches found for %s',sObj.pattern));
}
return sObj;
}
С парочкой небольших изменений в приведенном выше коде мы получаем следующие результаты:
Sheet: Crew_Traits Row: 13 Col: 4 Value: Ambassador columnA Value: Admiral Picard
Sheet: Crew_Traits Row: 31 Col: 4 Value: Ambassador columnA Value: Ambassador K'Ehleyr
Sheet: Crew_Traits Row: 32 Col: 4 Value: Ambassador columnA Value: Ambassador Neelix
Sheet: Crew_Traits Row: 34 Col: 4 Value: Ambassador columnA Value: Ambassador Shras
и теперь это код:
function regexSearch() {
var ss=SpreadsheetApp.openById('1I3N5DtdXGWFootaOCQM201K_ao2ZPWSWyw9_l7QcwQg');
var tf=ss.createTextFinder('Ambassador').useRegularExpression(true);
var all=tf.findAll();
var matches='';
for(var i=0;i<all.length;i++) {
if(all[i].getColumn()==4) {
var aValue=all[i].getSheet().getRange(all[i].getRow(),1).getValue();
matches+=Utilities.formatString('Sheet: %s Row: %s Col: %s Value: %s columnA Value: %s\n',all[i].getSheet().getName(),all[i].getRow(),all[i].getColumn(),all[i].getValue(),aValue);
}
}
Logger.log(matches);
return matches;
}