没有Google App脚本的问题解决程序

时间:2019-07-09 13:56:04

标签: google-apps-script

工作原理问题,类型错误:TypeError:Nãoépossívelencontrar afunçãoreplaceWith no objeto Spreadsheet。 (linha 4,arquivo“Código”)

function RemoverAcento(){
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
var textFinder = spreadsheet.createTextFinder('â');
var spreadreplace = textFinder.replaceWith('a');
return spreadreplace;}

1 个答案:

答案 0 :(得分:1)

您必须调用.replaceAllWith()而不是.replaceAll(),因为.replaceAll()在特定的单元格上工作。

function RemoverAcento(){
  var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
  var textFinder = spreadsheet.createTextFinder('â')
  var spreadreplace = textFinder.replaceAllWith('a');
  return spreadreplace;
}

或者,如果您只想对一个单元执行操作,则可以使用

function RemoverAcento(){
  var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
  var textFinder = spreadsheet.getSheets()[0].getRange(7, 4).createTextFinder('â')  var spreadreplace = textFinder.replaceAllWith('a');
  return spreadreplace;
}

.getSheets()[0].getRange(7, 4)是您要编辑的单元格。