繁体   English   中英

使用Google Apps脚本操纵Google文档上单元格的高度

[英]Manipulate height of cells on google document using google apps script

我正在尝试使用Google Apps Script在Google文档上绘制表格,然后将结果转换为PDF 那很好,但是我无法控制高度的细胞 这是我的代码:

var TemplateCopyBody = DocumentApp.openById("id").getActiveSection();
var tableStyle = {};
tableStyle[DocumentApp.Attribute.FONT_SIZE] = 8;
tableStyle[DocumentApp.Attribute.FONT_FAMILY] =  DocumentApp.FontFamily.UBUNTU;
tableStyle[DocumentApp.Attribute.BOLD] = 0;
tableStyle[DocumentApp.Attribute.HORIZONTAL_ALIGNMENT] = 0;
tableStyle[DocumentApp.Attribute.PADDING_RIGHT] = 0;
tableStyle[DocumentApp.Attribute.HEIGHT] = 0;


/* Function to populate my table */
var myTable = new Array();
for(var i=0;i<RESULT.marksDetails.length -1;i++){
  myTable[i] = RESULT.notesDetails[i];
  Logger.log("insertion table : "+i);
}


TemplateCopyBody.appendTable(myTable).setAttributes(tableStyle).setColumnWidth(0, 300);

我真的需要你的帮助!

要将每行的高度更改为45像素,将其他行的高度更改为22像素,我将执行以下操作:

var newTable = TemplateCopyBody.appendTable(myTable);
  for(var i=1; i < myTable.length ;i++){
    if(i % 2 == 0)
      newTable.getRow(i).setMinimumHeight(22);
    else
      newTable.getRow(i).setMinimumHeight(45);
  }
  newTable.setAttributes(tableStyle).setColumnWidth(0, 300);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM