我无法找到使用 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 脚本对齐表格有什么想法吗?