【发布时间】:2014-03-05 14:46:29
【问题描述】:
我通过脚本创建了一个谷歌文档,并希望通过此代码向其中插入表格:
var row1 = "some city"
var row2 = "some text"
var rowsData = [[row1, row2]];
var table = body.appendTable(rowsData);
table.setBorderWidth(0);
style[DocumentApp.Attribute.BOLD] = true;
style[DocumentApp.Attribute.HORIZONTAL_ALIGNMENT] = DocumentApp.HorizontalAlignment.CENTER;
table.setAttributes(style);
我希望单元格中的所有文本都是粗体并居中显示。但我看到只应用了粗体属性。 我尝试添加一些脚本
var cell1 = table.getCell(0, 0);
var cell2 = table.getCell(0, 1);
cell1.setAttributes(style);
cell1.editAsText().setAttributes(style);
但没有效果。
请告诉我如何正确地将单元格中的文本居中!
【问题讨论】:
标签: google-apps-script google-docs