我找不到使用 Google Apps Script 在 Google Doc 中水平对齐表格的方法。我已经彻底检查了所有文档,并且还盲目地尝试了几种方法。
尝试一:
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);
尝试二:
var cells = [
['Company', rowData[3]],
['Title', rowData[4]],
];
var mentorTable = body.appendTable(cells);
myTable.setAlignment(DocumentApp.HorizontalAlignment.RIGHT);
Google Docs UI 支持从“表格属性”菜单选项更改此属性。
关于如何使用 Google Apps 脚本对齐表格的任何想法?
最佳答案
我意识到这个问题相对较旧,但我发现以下内容对我有用。而不是直接在单元格上设置对齐方式,我需要将其设置为子项。
// create table
table = body.appendTable();
// add row
var tr = table.appendTableRow();
// add cell and right align
var td = tr.appendTableCell('hello world!');
td.getChild(0).asParagraph().setAlignment(DocumentApp.HorizontalAlignment.RIGHT);
关于google-apps-script - 如何在 Apps 脚本中设置表格的水平对齐方式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31525029/