Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Insert image into Google Sheets cell using Google Sheets API

In google apps Script you can insert an image into Google Spreadsheets using the insertImage function (https://developers.google.com/apps-script/reference/spreadsheet/sheet#insertimageblob-column-row).

But I'm not using appscript. I'm using the Google Sheets API (https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets) and I can't seem to find a way to do this. Is there any possible implementation?

like image 996
dedles Avatar asked Apr 27 '17 17:04

dedles


People also ask

Can I have an image and text in a cell in Google Sheets?

You can insert any image into any cell in Google Sheets in just a few steps. To insert an image into a Google Sheets cell: Open your sheet and select an empty cell. Click Insert in the menu, then hover over the Image sub-menu.

What is the shortcut to insert a picture into a cell in Google Sheets?

On Mobile: Tap once on a cell to select. Tap again to bring up menu: Insert > Tap the “+” at the top of the screen > Image > Image in cell. Select an image from the options presented to you.

How do I assign an image to a script in Google Sheets?

Return to Sheets and insert an image or drawing by selecting Insert > Image or Insert > Drawing. After inserting the image or drawing, click it. A small drop-down menu selector will appear in the top right-hand corner. Click it and choose Assign script.

How do I insert an image into bulk in Google Sheets?

Insert Multiple PicturesIn the Insert Picture window, hold CTRL on your keyboard and click on the pictures you want to insert. Then click Insert.


2 Answers

The V4 API doesn't have the ability to insert an image blob like Apps Script does (where the image is an overlay on the sheet, not associated with any cell). You may be able to workaround this using the =IMAGE function. We know of the gap in functionality and are looking into adding support for image blobs.

like image 161
Sam Berlin Avatar answered Oct 20 '22 14:10

Sam Berlin


Set the formula with script like this:

function showImage() {
 var ss=SpreadsheetApp.getActiveSpreadsheet() 
 var formulaSheet = ss.getSheetByName("Sheet1");
 var formulaCell = formulaSheet.getRange("B5");
 formulaCell.setFormula('=IMAGE("http://finviz.com/fut_chart.ashx?t=ES&p&p=m5&s=m",4,100,200)')
}
like image 23
Ed Nelson Avatar answered Oct 20 '22 16:10

Ed Nelson