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

时间:2016-10-28 12:44:36

标签: google-apps-script google-sheets

您好我想在google脚本的范围内设置中心对齐,但我不知道该怎么办。

我已经尝试了

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

但是元素setAlignment在范围

上不存在

1 个答案:

答案 0 :(得分:11)

试试这样:

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")
}