我想知道是否有办法以编程方式在Google幻灯片中创建演示文稿。因此,例如,如果基础数据发生变化,我可以刷新套牌而不需要为所有图表等进行大量复制粘贴。
类似于使用markdown和R slidify来生成数据驱动的PDF演示文稿。我的最终产品需要是漂亮的Google幻灯片演示文稿。
我可以使用Google Drive API吗?我不确定App Script是否可以用于幻灯片,就像你可以用于Sheets一样。
我希望解决方案存在的问题很普遍。
一种选择是自动生成PDF,然后手动导入Google幻灯片。问题是由于转换错误和缺少其他幻灯片功能,这种方法有点受限。
任何输入都非常赞赏。
答案 0 :(得分:6)
Google Slides API于2016年11月9日推出。它提供了阅读,创建和编辑Google幻灯片演示文稿的功能。
目前在Apps脚本中仍然没有相应的服务,但您可以使用Apps Script OAuth2 library和UrlFetchApp
在脚本中调用API。
答案 1 :(得分:4)
答案 2 :(得分:4)
2018 ,以及这个老问题的好消息(和答案!):
答案 3 :(得分:2)
Apps脚本中的一个示例:
UrlFetchApp
将经过身份验证的请求发送到Slides API 作为Apps脚本中的一个简单示例,请考虑fetching the latest version of a Presentation(presentations.get
)。
// Add your presentation ID
var presentationId = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
// Force add the Drive scope (as this comment *will* get parsed
// and trigger a popup to authorize Drive access)
// DriveApp.createFile('')
// URL formed as per the Slides REST documentation
var url = 'https://slides.googleapis.com/v1/presentations/' + presentationId;
var options = {
headers: {
Authorization: 'Bearer ' + ScriptApp.getOAuthToken()
}
};
var response = UrlFetchApp.fetch(url, options);
// Turn this back into a JS Object so it can be used.
var presentation = JSON.parse(response.getContentText());
// Log the ID of the presentation
Logger.log(presentation.presentationId);
// Log the number of slides...
Logger.log(presentation.slides.length);
// Loop through the slides
var slides = presentation.slides;
slides.forEach(function(slide) {
// ... do something with each slide...
});
REST引用中presentation
的结构为also documented。使用REST reference,此示例可以扩展为与任何幻灯片API请求和响应一起使用。