I am new to google script. I have a project to merge data from the google sheet into google slide. I need to create a slide where all data is merge into a single file slide. I have google many solution but it seems not working. Even though I have 10 data, but only the first data is merge into first slide only. Please help
Here are my codes:
function slidemerge()
{
// Use the Sheets API to load data, one record per row.
var srcSlideId = 'id';
var values = SpreadsheetApp.openById('ssid').getDataRange().getValues();
var copysrcSlideIndex = 1; // 0 means page 1.
var copydstSlideIndex = 2; // 0 means page 1.
// Duplicate the template presentation using the Drive API.
var copyTitle = 'Report'+ Utilities.formatDate(new Date(), "GMT+8", "dd-MMM-yyyy");
var copyFile = {
title: copyTitle,
parents: [{id: 'root'}]
};
copyFile = Drive.Files.copy(copyFile, srcSlideId);
var presentationCopyId = copyFile.id;
var src = SlidesApp.openById(presentationCopyId).getSlides()
[copysrcSlideIndex];
// For each record, create a new merged presentation.
for (var i = 1; i < values.length; ++i) {
var row = values[i];
var pid=row[9];
var customerName = row[10];
var slip=row[11];
var dupslideid=SlidesApp.openById(presentationCopyId).insertSlide(copydstSlideIndex, src);
// Create the text merge (replaceAllText) requests for this presentation.
requests = [{
replaceAllText: {
pageObjectIds: src[dupslideid.getObjectId()],
containsText: {
text: '{{ID}}',
matchCase: true
},
replaceText: pid,
}
},{
replaceAllText: {
containsText: {
text: '{{Name}}',
matchCase: true
},
replaceText: customerName
}
},{
replaceAllShapesWithImage: {
imageUrl: slip,
replaceMethod: 'CENTER_INSIDE',
containsText: {
text: '{{Slip}}',
matchCase: true
}
}
}];
// Execute the requests for this presentation.
var result = Slides.Presentations.batchUpdate({
requests: requests
}, presentationCopyId);
}
}