0
我有一些代碼用於Google應用腳本宏。這使用DocumentApp TableRow和Table Cell數據類型。Google Apps Script TableCell不接受屬性
//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);