我无法找到使用 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);
尝试二:
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);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)