小编Sea*_*day的帖子

如何在 Apps 脚本中设置表格的水平对齐方式

我无法找到使用 Google Apps 脚本水平对齐 Google 文档中表格的方法。我彻底检查了所有文档,也盲目地尝试了几种方法。

尝试一:

var cells = [
  ['Company', rowData[3]],
  ['Title', rowData[4]],
];

var tableStyle = {};
tableStyle[DocumentApp.Attribute.HORIZONTAL_ALIGNMENT] = DocumentApp.HorizontalAlignment.RIGHT;

var mentorTable = body.appendTable(cells);

var myTable = body.appendTable(cells);
myTable.setAttributes(tableStyle);
Run Code Online (Sandbox Code Playgroud)

尝试二:

var cells = [
  ['Company', rowData[3]],
  ['Title', rowData[4]],
];

var mentorTable = body.appendTable(cells);
myTable.setAlignment(DocumentApp.HorizontalAlignment.RIGHT);
Run Code Online (Sandbox Code Playgroud)

Google Docs UI 支持从“表属性”菜单选项更改此属性。

关于如何使用 Google Apps 脚本对齐表格有什么想法吗?

google-docs-api google-apps-script

6
推荐指数
2
解决办法
5948
查看次数