How to automatically update charts linked to Google Sheets?

后端 未结 3 522
情书的邮戳
情书的邮戳 2020-12-17 04:08

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 fo

3条回答
  •  鱼传尺愫
    2020-12-17 05:11

    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.

提交回复
热议问题