我正在创建工作表插件以将名称标签从 Google 工作表列表打印到 Google 幻灯片文档。一张幻灯片将包含名称标签和公司名称。创建幻灯片时我无法插入标题。
var dataRangeNotation = 'Customers!A2:M6';
var values = SpreadsheetApp.openById('').getRange(dataRangeNotation).getValues();
var presentationId = ''
var requests = []
// For each record, create a new merged presentation.
for (var i = 0; i < values.length; ++i) {
var row = values[i];
var customerName = row[0]; // name in column 1
var customerCompany = row[1]; // company description in column 2
var pageId = Utilities.getUuid();
var bodyId = Utilities.getUuid();
var titleID = Utilities.getUuid();
requests.push({
'createSlide': {
'objectId': pageId,
'insertionIndex': 0,
'slideLayoutReference': {
'predefinedLayout': 'TITLE'
},
"placeholderIdMappings": [
{
"layoutPlaceholder": {
"type": "TITLE",
"index": 0
},
"objectId": titleID,
},
{
"layoutPlaceholder": {
"type": "BODY",
"index": 0
},
"objectId": bodyId,
},
],
},
{
"insertText": {
"objectId": titleID,
"text": "This is my slide title",
},
},
});
},
var slide =
Slides.Presentations.batchUpdate({'requests': requests}, presentationId);
Logger.log('Created Slide with ID: ' + slide.replies[0].createSlide.objectId);
布局 placeholerIdMappings 不起作用。我不想创建幻灯片然后循环幻灯片以更改幻灯片标题。寻找已经插入请求的方法。