我正在尝试从模板文件在 Google 文档中生成报告。当它复制文档时,它会将所有格式重置为用户的默认格式,而不是原始文档中的格式。我尝试了以下方法来尝试在文档、tableRow 和 tableCell 级别上设置格式,但创建报告时行距为 1.5 并且段落后有一个空格
var style = {};
style[DocumentApp.Attribute.SPACING_AFTER] =0;
style[DocumentApp.Attribute.SPACING_BEFORE] =0;
style[DocumentApp.Attribute.LINE_SPACING]=1;
var newrow= tables[2].insertTableRow(n).setBold(false).setAttributes(style);
if(j==0){
newrow.insertTableCell(0,reportDate).setPaddingBottom(0).setPaddingTop(0).setAttributes(style);
}
else{
newrow.insertTableCell(0,'').setPaddingBottom(0).setPaddingTop(0).setAttributes(style);
}
newrow.insertTableCell(0,values1[rowId1][1]+' '+values1[rowId1][2]).setPaddingBottom(0).setPaddingTop(0).setAttributes(style);
newrow.insertTableCell(0,'').setPaddingBottom(0).setPaddingTop(0).setAttributes(style);
doc.editAsText().setAttributes(style);
关于如何让报告遵循这些属性有什么建议吗?
我相信 SPACING AFTER、SPACING BEFORE 和 LINE SPACING 不是与 TABLE_CELL 对象关联的属性。您必须引用子段落才能设置它们。
var style = {};
style[DocumentApp.Attribute.SPACING_AFTER] =0;
style[DocumentApp.Attribute.SPACING_BEFORE] =0;
style[DocumentApp.Attribute.LINE_SPACING]=1;
var newrow = tables[2]
.insertTableRow(n)
.setBold(false);
if (j == 0) {
newrow.insertTableCell(0,reportDate)
.setPaddingBottom(0)
.setPaddingTop(0);
}
else {
newrow.insertTableCell(0,'').setPaddingBottom(0).setPaddingTop(0);
}
newrow.insertTableCell(0,values1[rowId1][1]+' '+values1[rowId1][2])
.setPaddingBottom(0)
.setPaddingTop(0);
newrow.insertTableCell(0,'')
.setPaddingBottom(0)
.setPaddingTop(0);
var newrowTableCell = newrow.getChild(0);
var newrowParagraph = newrowTableCell.getChild(0).setAttributes(style);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)