[]
This function input an URL or a base64 string to show an image in cell.
IMAGE(url, [mode, height, width, clipX, clipY, clipHeight, clipWidth, vAlign, hAlign])
Argument | Description |
---|---|
URL | The location of the image on the web or base64 string. |
mode | (Optional) Specifies how to size the image. 1 - Keep the aspect ratio to fit the cell. 2 - Stretch the image to cover the entire cell. 3 - Keep original size even if cropped. 4 - custom The default value is 1. |
height | (Optional) The height of image. The mode option must be 4. |
width | (Optional) The width of image. The mode option must be 4. |
clipX | (Optional) The x-axis coordinate of the top left corner of the source image sub-rectangle to draw into the destination context. The default value is 0. |
clipY | (Optional) The y-axis coordinate of the top left corner of the source image sub-rectangle to draw into the destination context. The default value is 0. |
clipHeight | (Optional) The height of the source image sub-rectangle to draw into the destination context. The default value is the height of image. |
clipWidth | (Optional) The width of the source image sub-rectangle to draw into the destination context. The default value is the width of image. |
vAlign | (Optional) Vertical alignment of the image. 0 - Top 1 - Center 2 - Bottom The default value is 1 (center). |
hAlign | (Optional) Horizontal alignment of the image. 0 - Left 1 - Center 2 - Right The default value is 1 (center). |
Returns sparkline.
sheet1.setFormula(2, 0, '=IMAGE("https://upload.wikimedia.org/wikipedia/commons/thumb/f/fa/Flag_of_the_People%27s_Republic_of_China.svg/23px-Flag_of_the_People%27s_Republic_of_China.svg.png")');
sheet1.setFormula(3, 0, '= IMAGE("https://upload.wikimedia.org/wikipedia/en/4/41/Flag_of_India.svg")');