SpreadsheetApp.insertImage 服务器错误 [英] SpreadsheetApp.insertImage server error

查看:19
本文介绍了SpreadsheetApp.insertImage 服务器错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么下面的代码在 GSuite 电子表格中返回服务器错误"?

Why the below code return 'server error' in GSuite Spreadsheet?

function test() {
  var ss = SpreadsheetApp.openById('1Wc6nKxxxxxxxxxxxxxxxxxx0Ld6QyaY');
  var sheet = ss.getSheetByName('2018.0801-0831');
  var img = DriveApp.getFileById('1qw2uy3cNxxxxxxxxxxxxxxxxxDZRES');
  var imgBlob = img.getBlob();
  sheet.insertImage(imgBlob, 9, 20);
}

图像为 JPEG,276KB.图像大小为 173KB,此代码有效.是否可以插入大图像块?

The Image is JPEG, 276KB. With an image its size is 173KB, this code is working. Is it possible to insert large imageBlobs?

推荐答案

以我的经验,当通过insertImage()插入图像时,限制是由于图像区域(像素^2) 而不是它的文件大小.可插入图片的最大区域为 1,048,576 像素^2.

In my experience, when an image is inserted by insertImage(), the limitation is due to the image area (pixels^2) rather than the file size of it. The maximum area of image which can be inserted is 1,048,576 pixels^2.

我进行了如下实验.

  • 可以插入以下尺寸的图像.
    • 1024 像素 x 1024 像素
    • 2048 像素 x 512 像素
    • 4096 像素 x 256 像素
    • 1025 像素 x 1025 像素
    • 1024 像素 x 1025 像素
    • 1025 像素 x 1024 像素

    从这些结果中,我得出结论,插入图像的限制是 1,048,576 像素 ^2.

    From these results, I concluded the limitation for inserting image is 1,048,576 pixels^2.

    因此,如果您要插入的图像区域超过 1,048,576 像素 ^2,请调整其大小并重试.

    So if the area of image you want to insert is more than 1,048,576 pixels^2, please resize it and try again.

    这篇关于SpreadsheetApp.insertImage 服务器错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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