Google ドキュメントに、1 ページを含むテンプレート ドキュメントがあります。テンプレート ドキュメントの 1 ページと同じ N ページの新しいドキュメントを作成したいと考えています。
これどうやってするの?
Google ドキュメントに、1 ページを含むテンプレート ドキュメントがあります。テンプレート ドキュメントの 1 ページと同じ N ページの新しいドキュメントを作成したいと考えています。
これどうやってするの?
Henrique のこの投稿を見てください。ドキュメントで利用可能な定義に従って、さまざまなドキュメント要素を使用しています。必要なものを選択して、対応するルーチンを追加する必要があります。
これがその方法です(元の投稿のコード):
function mergeDocs() {
var docIDs = ['list-of','documents','ids','you should have somehow'];
var baseDoc = DocumentApp.openById(docIDs[0]);
var body = baseDoc.getActiveSection();
for( var i = 1; i < docIDs.length; ++i ) {
var otherBody = DocumentApp.openById(docIDs[i]).getActiveSection();
var totalElements = otherBody.getNumChildren();
for( var j = 0; j < totalElements; ++j ) {
var element = otherBody.getChild(j).copy();
var type = element.getType();
if( type == DocumentApp.ElementType.PARAGRAPH )
body.appendParagraph(element);
else if( type == DocumentApp.ElementType.TABLE )
body.appendTable(element);
else if( type == DocumentApp.ElementType.LIST_ITEM )
body.appendListItem(element);
else
throw new Error("According to the doc this type couldn't appear in the body: "+type);
}
}
}