我成功将图片插入谷歌电子表格......
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
sheet.insertImage("https://www.google.com/images/srpr/logo3w.png", 1, 1, 10, 10);
但是一旦插入图像,有没有办法处理它们? 例如,有没有办法重新定位它们?删除它们?调整大小。等
(最终我想重新定位)
顺便说一下,图片是通过网址插入的。是保留了网址的链接,还是现在作为电子表格中的对象存在? 我似乎找不到查看图像属性的方法。
答案 0 :(得分:3)
几天前见this question I answered。从本质上讲,您无法在插入图像后以编程方式删除或操作图像。但是,您可以将= IMAGE()公式插入单元格并删除或修改它。
答案 1 :(得分:2)
As of now, October of 2018, there are ways to manipulate images in sheet. It seems it's at experimental stages and documentation is not fully done yet. The working code for resizing and deleting is described here (again, there is no official documentation). This answer's purpose is to make sure that those that reached here will have a more timely answer than the accepted one in 2014.
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
var imgLnk = 'link of the image';
sheet.insertImage(imgLnk, 2, 2); //This insert image at B2
var img = sheet.getImages()[0]; //Assuming there is only 1 image in the sheet
img.setAnchorCell('N1');
The last line img.setAnchorCell
may not work for you. It's known that experimental feature like this work differently for different people. The case proven is function delete()
use to delete image does not work the same way for different people.