问题描述
我有一个 Google 幻灯片演示文稿,其中包含链接到特定 Google 表格电子表格的图表.
I have a Google Slides presentation with charts that are linked to a specific Google Sheets Spreadsheet.
由于演示文稿中有很多图表,我正在寻找一种方法来自动更新所有这些链接的图表,或者至少一次更新所有这些图表.
As there are many charts in the presentation, I'm looking for a way to update all these linked charts automatically, or at least all of them at once.
最好的方法是什么?
推荐答案
您可以使用以下脚本将自定义函数添加到幻灯片 UI 的下拉菜单中.这会从当前演示文稿中获取幻灯片,循环浏览它们,获取每张幻灯片中的任何图表并刷新(更新)它们.
You can add a custom function to a dropdown menu in the Slides UI with the following script. This gets the slides from the current presentation, loops through them, gets any charts in each slides and refreshes (updates) them.
function onOpen() {
var ui = SlidesApp.getUi();
ui.createMenu('Custom Menu')
.addItem('Batch Update Charts', 'batchUpdate')
.addToUi();
}
function batchUpdate(){
var gotSlides = SlidesApp.getActivePresentation().getSlides();
for (var i = 0; i < gotSlides.length; i++) {
var slide = gotSlides[i];
var sheetsCharts = slide.getSheetsCharts();
for (var k = 0; k < sheetsCharts.length; k++) {
var shChart = sheetsCharts[k];
shChart.refresh();
}
}
}
注意:在此回复时,更新/刷新链接幻灯片的功能似乎不存在.
Note: The functionality to update/refresh linked Slides doesn't appear to exist at the time of this response.
这篇关于如何自动更新链接到 Google Sheets 的图表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!