简体   繁体   中英

How do you select and delete drawings in google sheets with a script?

I'm writing a google script that copies a sheet and pastes it into another spreadsheet, but I have to automatically delete the drawings that are present there. How do I do that? I couldn't find any documentation on the matter. I have tried using the getCharts() function, but while debugging I realized that it remained empty.

var charts = thisSheet.getCharts();
for (var i in charts) {
  thisSheet.removeChart(charts[i]);
}
var drawings = SpreadsheetApp.getActiveSheet().getDrawings();
...
drawing.remove();

https://developers.google.com/apps-script/reference/spreadsheet/drawing

var drawings = SpreadsheetApp.getActiveSheet().getDrawings();
for (var i = 0; i < drawings.length; i++) {
  drawings[i].remove();
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM