【发布时间】:2022-09-23 20:46:25
【问题描述】:
感谢@Tanaike 为我之前的问题提供了答案。我还有另外两个问题。
1 - 当设置间距为 1 但在 Google Doc 中检查时,间距为 1.15。
heading1Style[DocumentApp.Attribute.LINE_SPACING] = 1;
2 - 我尝试将 DocumentApp.ParagraphHeading.Heading1 设置为以下,但它不起作用。
tableRow1.getCell(0, 1).editAsText().setAttributes(heading1Style);
以下是整个代码。
function insertHeading1() {
var heading1Style = {};
heading1Style[DocumentApp.Attribute.FONT_FAMILY] = \'Calibri\';
heading1Style[DocumentApp.Attribute.FONT_SIZE] = 18;
heading1Style[DocumentApp.Attribute.HORIZONTAL_ALIGNMENT] = DocumentApp.HorizontalAlignment.LEFT;
heading1Style[DocumentApp.Attribute.LINE_SPACING] = 1;
heading1Style[DocumentApp.Attribute.BOLD] = true;
var cells = [
[\' \', \'HEADING 1, CALIBRI, 18PT, BOLD, LEFT ALIGNED, ALL CAPS, SINGLE SPACING, NO SPACE BEFORE AND AFTER PARAGRAPH\'],
];
var tableRow1 = body.appendTable(cells);
tableRow1.setColumnWidth(0, 10);
tableRow1.getCell(0, 0).setBackgroundColor(\'#1c3a69\');
tableRow1.getCell(0, 1).editAsText().setAttributes(heading1Style);
}