Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to automatically update charts linked to Google Sheets?

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.

What is the best way to do this?

like image 996
AviG Avatar asked Jun 12 '17 10:06

AviG


People also ask

Do linked Google Sheets automatically update?

More on CSV LinksSheets will update the data automatically at up to 1 hour intervals , using the IMPORTDATA() function, which is very similar to IMPORTRANGE(). To force a refresh of the data synced into Sheets, you can go to the cell in Sheets which has the formula, delete it, and then undo the change.


1 Answers

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.

like image 79
Aleister Tanek Javas Mraz Avatar answered Nov 13 '22 23:11

Aleister Tanek Javas Mraz