通过脚本错误删除Google工作表中的图像 [英] Deleting images in Google sheet via script error

查看:72
本文介绍了通过脚本错误删除Google工作表中的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可能会为此而感到沮丧,但我无能为力.我搜索,阅读并尝试了很多东西.我在Javascript和Google平台上都是新手.

I probably will get downvoted for this but I can't do anything else. I searched, read and tried SOOOO many things. I am new at both Javascript and Google platform.

我有一段不断告诉我的代码

I have this piece of code that keeps telling me

.操作后缺少名称".

"Missing name after . operation".

即使.delete.getAltTextTitle都显示在自动填充建议中

Even though .delete and .getAltTextTitle are both shown in autocomplete suggestion

  var images = sheet.getImages();
  var img = images[0];
  Logger.log(img.getAltTextTitle()); //This is fine
  img.delete(); //This throw error

同时,我的这段代码工作得很好.我不知道该怎么办.它们对我来说看起来一样.

In the meanwhile, I have this piece of code working totally fine. I don't know what to do. They look the same to me.

  var img = sheet.getImages()[0];
  var imgH = img.getHeight();
  var imgW = img.getWidth();
  var maxW = 700;
  var newImgH = Math.round(imgH*(maxW/imgW));
  img.setWidth(maxW);
  img.setHeight(newImgH);

不相关的主题,在哪里可以找到sheet.getImages()的文档,因为我只是找不到它此处

Unrelated topic, where do I get the documentation for sheet.getImages() because I just couldn't find it here

推荐答案

  • 您要使用Google Apps脚本删除电子表格上的图像.
  • 如果我的理解是正确的,我认为delete()可能是新方法,将在不久的将来为电子表格添加.因此,该文档尚未更新,因此可能尚未完成.但是从错误消息中,如果您想使用当前的delete()方法,该示例脚本如何?

    If my understand is correct, I think that delete() might be new method which will be added for Spreadsheet in the near future. So the document is not updated and it might not complete yet. But from the error message, if you want to use the current delete() method, how about this sample script?

    var images = sheet.getImages();
    var img = images[0];
    img["delete"](); // this one
    

    注意:

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆