【发布时间】:2017-06-07 19:32:52
【问题描述】:
我有一些用于谷歌应用脚本宏的代码。这使用 DocumentApp TableRow 和 Table Cell 数据类型。
//row is TableRow datatype
function appendRow(row){
var style = {};
style[DocumentApp.Attribute.FONT_SIZE] = '8';
style[DocumentApp.Attribute.HORIZONTAL_ALIGNMENT] = DocumentApp.HorizontalAlignment.RIGHT;
row.appendTableCell(SOME_TEXT).setAttributes(style);
}
所以当我运行这个函数时,行中的结果单元格仍然是默认的左对齐。我错过了什么吗?他们的网站上有这个例子。
https://developers.google.com/apps-script/reference/document/table-cell#setAttributes(Object)
var body = DocumentApp.getActiveDocument().getBody();
// Define a custom paragraph style.
var style = {};
style[DocumentApp.Attribute.HORIZONTAL_ALIGNMENT] =
DocumentApp.HorizontalAlignment.RIGHT;
style[DocumentApp.Attribute.FONT_FAMILY] = 'Calibri';
style[DocumentApp.Attribute.FONT_SIZE] = 18;
style[DocumentApp.Attribute.BOLD] = true;
// Append a plain paragraph.
var par = body.appendParagraph('A paragraph with custom style.');
// Apply the custom style.
par.setAttributes(style);
【问题讨论】: