From 3c6a9c783942225333f9ff0741659d0be1834c3b Mon Sep 17 00:00:00 2001 From: David Campbell Date: Mon, 17 Oct 2016 14:50:15 -0400 Subject: [PATCH 1/2] Updated enumeration --- merge.gs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/merge.gs b/merge.gs index 490206d..e09ca4c 100644 --- a/merge.gs +++ b/merge.gs @@ -1,4 +1,4 @@ -/* This is the main method that should be invoked. +/* This is the main method that should be invoked. * Copy and paste the ID of your template Doc in the first line of this method. * * Make sure the first row of the data Sheet is column headers. @@ -25,7 +25,7 @@ function doMerge() { var values = rows.getValues(); var fieldNames = values[0];//First row of the sheet must be the the field names - for (var i = 1; i < numRows; i++) {//data values start from the second row of the sheet + for (var i = 1; i < numRows; i++) {//data values start from the second row of the sheet var row = values[i]; var body = bodyCopy.copy(); @@ -44,7 +44,7 @@ function doMerge() { mergedDoc.appendImage(child.getBlob()); } else if (child.getType() == DocumentApp.ElementType.PARAGRAPH) { mergedDoc.appendParagraph(child); - } else if (child.getType() == DocumentApp.ElementType.LISTITEM) { + } else if (child.getType() == DocumentApp.ElementType.LIST_ITEM) { mergedDoc.appendListItem(child); } else if (child.getType() == DocumentApp.ElementType.TABLE) { mergedDoc.appendTable(child); From bb5749310ef403ace78129b221a72b961c1a1de2 Mon Sep 17 00:00:00 2001 From: David Campbell Date: Thu, 27 Oct 2016 01:02:17 -0400 Subject: [PATCH 2/2] Update merge.js Fixed an issue where long sheets would cause an error. --- merge.gs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/merge.gs b/merge.gs index e09ca4c..f6958b9 100644 --- a/merge.gs +++ b/merge.gs @@ -54,7 +54,10 @@ function doMerge() { } mergedDoc.appendPageBreak();//Appending page break. Each row will be merged into a new page. - + if(i % 50 == 0) { //Merging long sheets causes an error without ocassionally closing/reopening the file. + mergedDoc.saveAndClose(); + mergedDoc = DocumentApp.openById(mergedFile.getId()); + } } }