我正在尝试使用以下代码来设置自定义行高,但它永远不会被应用。文档'测试报告'有1行,该行有默认高度。有什么问题?
var targetDoc = DocumentApp.create('Test report');
var body = targetDoc.getBody();
body.setAttributes({MARGIN_LEFT: 15,
MARGIN_RIGHT: 15,
MARGIN_TOP: 15,
MARGIN_BOTTOM: 15,
PAGE_WIDTH: 595,
PAGE_HEIGHT: 842});
var t1 = body.appendTable([['1','2','3','4']]);
t1.setBorderColor('#FFFFFF');
var attrs = {};
attrs[DocumentApp.Attribute.MINIMUM_HEIGHT] = 35;
t1.setAttributes(attrs);
答案 0 :(得分:2)
请参阅文档here:
MINIMUM_HEIGHT Enum The minimum height setting in points, for table row elements.
在您的代码中,您将其设置为Table
属性。您需要改为t1.getRow(0).setMinimumHeight(35);
。所以工作代码看起来像这样:
function test() {
var targetDoc = DocumentApp.create('Test report');
var body = targetDoc.getBody();
body.setAttributes({MARGIN_LEFT: 15,
MARGIN_RIGHT: 15,
MARGIN_TOP: 15,
MARGIN_BOTTOM: 15,
PAGE_WIDTH: 595,
PAGE_HEIGHT: 842});
var t1 = body.appendTable([['1','2','3','4']]);
t1.setBorderColor('#FFFFFF');
t1.getRow(0).setMinimumHeight(35);
return;
}
请注意,您要以磅为单位设置高度,而不是厘米或桌面属性在文档上显示的任何其他内容!