How To Download Image From Google Sheets

Google Sheets, a powerful online spreadsheet program, allows users to organize data, perform calculations, and even embed images. But what if you’ve been given a Google Sheet with images that you need to download? Unfortunately, Google Sheets doesn’t provide a straightforward command to save images onto your device. However, there’s a workaround that lets you extract and save images. Here’s how you can do it:

1. Use the Image in Cell Functionality

If the images are embedded in cells using the IMAGE function, then you’ll need to parse the cell to get the URL of the image.

// Assume the IMAGE function is used in cell A1
var cell = SpreadsheetApp.getActiveSpreadsheet().getRange('A1');
var formula = cell.getFormula();
var url = formula.match(/"(.*?)"/)[1];

After obtaining the URL of the image using the above script, you can paste it into a web browser and download the image by right-clicking on it and choosing the “Save image as…” option. Please make sure to replace ‘A1’ with the actual cell containing the image.

2. Use Google Apps Script to Download an Image

If you’re comfortable with Google Apps Script, you can use it to download images from Google Sheets. Here’s how you can do it:

function downloadImage() {
    var ss = SpreadsheetApp.getActiveSpreadsheet();
    var sheet = ss.getSheets()[0]; // Assuming image is in the first sheet
    var range = sheet.getRange("A1"); // Assuming image is in cell A1
    var blob = range.getBlob();
    var file = DriveApp.createFile(blob);
    Logger.log(file.getUrl());
}

In the above script:

  • SpreadsheetApp.getActiveSpreadsheet() gets the current active spreadsheet.
  • ss.getSheets()[0] gets the first sheet in the spreadsheet.
  • sheet.getRange(“A1”) gets the cell in which the image is located.
  • range.getBlob() retrieves the image as a binary object (or blob).
  • DriveApp.createFile(blob) creates a new file in your Google Drive using the blob.
  • The last line logs the URL of the newly created file in your Google Drive.

Please remember to replace ‘A1’ with the actual cell containing the image.

This method will save the image directly to your Google Drive, from where you can easily download it to your device.

Conclusion

While Google Sheets might not offer a direct solution for downloading images, the above methods provide effective workarounds. Whether you’re dealing with images embedded with the IMAGE function or directly inserted into cells, these steps will help you extract and download what you need. As always, make sure to replace the cell references with the actual ones containing your images.