Using Google appscript to refresh tables pasted in from Google sheets into Google slides

旧街凉风 提交于 2020-03-23 07:27:44

问题


This question here has as succinct solution for updating Google Sheets charts linked to Google slides.

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();
    }
  }
}

I wish to do the same thing but with a table pasted into Google Slides from Google Sheets. I can't see how this would look in the AppScript API for Google Slides. Can someone point out a way forward?


回答1:


I found this workaround in the issuetracker link provided by Leo as a comment to OP on Oct 30 '18:

"If anyone is reading this who wants the feature, one solution is to create a "table chart" in your sheet, from your existing table (that you were trying to link/update). It doesn't allow you to copy and paste from Sheets to Slides, but within Slides if you go to Insert -> Chart -> From Spreadsheet, then choose your sheet and chart (table). You can then use app scripts to automatically update it, as you can with a chart."

From ad...@lovecrafts.com




回答2:


First you can use a similar variable as

var sheetsTables = slide.getTables() 

and then use a for() loop to update each table in each slide. However, I don´t know which method you can use. If you know of one, please share.



来源:https://stackoverflow.com/questions/48665888/using-google-appscript-to-refresh-tables-pasted-in-from-google-sheets-into-googl

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!