如何使用google-script在Google电子表格中设置对齐范围?

Jus*_*Dev 4 google-sheets google-apps-script

您好我想在谷歌脚本的范围内设置中心对齐,但我不知道我该怎么做.

我已经尝试过了

sheet_destination.getRange(last_row_desti+1,1,1,4).setAlignment(DocumentApp.HorizontalAlignment.CENTER);

但是元素setAlignment在一个范围内不存在

Ed *_*son 14

试试这样:

function myFunction() {
  var ss = SpreadsheetApp.getActiveSpreadsheet()
  var s= ss.getActiveSheet()
  var lr = s.getLastRow()
  var r= s.getRange(1, 1, lr,4)
  var set=r.setHorizontalAlignment("center")
}
Run Code Online (Sandbox Code Playgroud)