google-apps-script - 如何自动调整图像大小以适合 Google 表格中的单元格?

标签 google-apps-script google-sheets google-sheets-formula

Windows 10 Google 表格

我有一张工作表,它根据我在父单元格中放入的超链接自动将图像放入单元格中。 enter image description here

基本上,单元格 E14、G14、I14 和 K14 都使用公式 =iferror(arrayformula(image(number)),"")数字等于带有链接的单元格,因此 G7、H7、I7、J7

这一切都很好,但我遇到的问题是图像太小、太宽、太高或太大。

我想知道是否有一种方法可以在将图像放入单元格时自动调整图像大小。

如果您查看下面的图片,您可以看到图像的白色边缘,表明它们不适合列宽和行高。

enter image description here

它应该看起来这样。

enter image description here

有办法做到这一点吗?如果有必要的话,我愿意编写一个脚本。如有任何建议,我们将不胜感激!

最佳答案

尝试IMAGE(url,2)


来自https://support.google.com/docs/answer/3093333?hl=en

mode - [ OPTIONAL - 1 by default ] - The sizing mode for the image

1 resizes the image to fit inside the cell, maintaining aspect ratio.

2 stretches or compresses the image to fit inside the cell, ignoring aspect ratio.

3 leaves the image at original size, which may cause cropping.

4 allows the specification of a custom size.

请注意,没有模式会导致单元格大小调整以适合图像。

关于google-apps-script - 如何自动调整图像大小以适合 Google 表格中的单元格?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64850275/

相关文章:

html - Google Apps 脚本 - 将用户输入从侧边栏写入电子表格

typescript - JSDoc 中 Google Apps 脚本在线与本地的类型表示法不兼容

javascript - 如何将一张纸的范围复制到另一张纸的范围,然后重复复制到下一行

arrays - 谷歌表格公式中数组大小的限制是多少?

javascript - 不工作 : Code to send email reminder based on date

javascript - 如何将 Google 表格中的列值与 Google Apps 脚本合并

javascript - Google 脚本 - 从单个单元格获取范围

arrays - 使用转置公式谷歌表格对多行求和

google-sheets - 使用哪些函数根据某一列中包含的数据来交替行组的颜色?

javascript - 来自电子表格 Javascript 的电子邮件 : How to make message equal more than one column?