4

テンプレート ファイルから 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);

レポートをこれらの属性に従わせるための提案はありますか?

4

3 に答える 3

1

設定された属性は属性を設定しておらず、どの要素も段落としてキャストできないため、すべての段落を取得し、最後にこれを追加して手動で設定することで、この問題を解決しました

var p=doc.getParagraphs();
  for(i=0;i<p.length; i++){
    p[i].setLineSpacing(1).setSpacingAfter(0);
于 2012-11-29T18:30:25.987 に答える
0

ユーザーはレポートを編集できる必要がありますか、それとも単に表示できる必要がありますか? なぜpdfを生成しないのですか?それを行うたびに、フォーマットが保存されます。

var file = DocsList.getFileById('1DIfn_wVpXSI4hU5zG43Fvp2ZdpUP_KqgtgFRT9NWJ7E');
var newFile = DocsList.copy(file, ename+'-'+reportDate+'Monthly Report');
var report=DocsList.createFile(newFile.getAs("application/pdf")).rename(newFile.getName() + ".pdf");
var a = report.getID();
var doc = DocumentApp.openById(a);
于 2012-11-19T19:13:45.027 に答える