2017-12-18 2 views
0

Google 문서 도구의 새로운 기능으로 현재 "찾기 및 바꾸기"기능에 변경 형식 기능을 추가하기위한 기존 스크립트를 찾고 있습니다. 예를 들어 B 열을 선택하고 단어의 모든 인스턴스를 찾고 "찾기 및 바꾸기"를 사용하고 단어를 바꿀 수있는 대신 서식을 굵게 또는 기울임 꼴로 변경하는 기능이 있습니다."찾기 및 바꾸기"기능에 변경 형식 기능을 추가하는 스크립트

제가 직접 검색 한 적이 없으므로 아무 것도 찾을 수 없으므로 누구든지 스크립트를 알고 있다면 크게 감사하겠습니다.

그렇지 않다면 누군가이 스크립트를 직접 만드는 것과 관련하여 시작할 곳을 알려주세요.

감사합니다.

답변

1

이 코드를 사용하여 Google 문서 도구에서 텍스트를 찾아서 바꿀 수 있지만 형식의 발견 된 텍스트를 변경하려면 수정해야합니다.

function replaceInSheet(sheet, to_replace, replace_with) { 
    //get the current data range values as an array 
    var values = sheet.getDataRange().getValues(); 

    //loop over the rows in the array 
    for(var row in values){ 

    //use Array.map to execute a replace call on each of the cells in the row. 
    var replaced_values = values[row].map(function(original_value){ 
     return original_value.toString().replace(to_replace,replace_with); 
    }); 

    //replace the original row values with the replaced values 
    values[row] = replaced_values; 
    } 

    //write the updated values to the sheet 
    sheet.getDataRange().setValues(values); 
}