Comments on: 5 Simple Ways to Insert Google Sheets Images https://spreadsheetpoint.com/insert-image-in-cell-google-sheets/ Google Sheets Tips & Tutorials Mon, 05 Aug 2024 19:25:46 +0000 hourly 1 https://wordpress.org/?v=6.7.1 By: jmarkus https://spreadsheetpoint.com/insert-image-in-cell-google-sheets/#comment-16163 Mon, 05 Aug 2024 19:25:46 +0000 https://spreadsheetpoint.com/?p=931#comment-16163 In reply to Alex.

I haven’t tried it, but that sounds like a helpful resource. Thanks for mentioning it!

]]>
By: Alex https://spreadsheetpoint.com/insert-image-in-cell-google-sheets/#comment-16153 Sun, 04 Aug 2024 19:23:33 +0000 https://spreadsheetpoint.com/?p=931#comment-16153 Have you tried FileDrop for inserting images in your Google Sheets documents? it’s a simple Google Sheets add-on that you can install directly from the Google WorkSpace marketplace. You don’t apps script and works really well.

]]>
By: jmarkus https://spreadsheetpoint.com/insert-image-in-cell-google-sheets/#comment-13474 Fri, 02 Feb 2024 12:48:22 +0000 https://spreadsheetpoint.com/?p=931#comment-13474 In reply to Claire.

That usually means the variable sheetRange is not declared or defined before it’s used in your script. You might try something like this:
function insertImage() {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();

// Define the range where you want to insert the image (e.g., A1)
var sheetRange = sheet.getRange('A1');

// Insert the image URL
var imageUrl = 'YourImageURL';
sheetRange.setFormula('=IMAGE("' + imageUrl + '")');
}

Here, ‘yourimageurl’ should be replaced with your image’s URL.

]]>
By: jmarkus https://spreadsheetpoint.com/insert-image-in-cell-google-sheets/#comment-13469 Fri, 02 Feb 2024 12:39:29 +0000 https://spreadsheetpoint.com/?p=931#comment-13469 In reply to Tan.

What error are you seeing?

]]>
By: jmarkus https://spreadsheetpoint.com/insert-image-in-cell-google-sheets/#comment-13468 Fri, 02 Feb 2024 12:38:58 +0000 https://spreadsheetpoint.com/?p=931#comment-13468 In reply to david.

If you have a large number of image URLs to import and embed into your Google Sheets and PDF, you can modify the script to handle multiple images in a more automated way. Here’s an updated version of the script that can handle a dynamic number of images:

function convertSheetToPDFAndEmail() {
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
var sheet = spreadsheet.getSheetByName('YourSheetName'); // Replace 'YourSheetName' with the actual sheet name
var range = sheet.getDataRange();
var data = range.getValues();
var urlColumnIndex = 1; // Adjust this to the column index where image URLs are located

// Fetch all image URLs
var imageUrls = [];
for (var i = 1; i < data.length; i++) { var imageUrl = data[i][urlColumnIndex - 1]; // Adjust to 0-based index imageUrls.push(imageUrl); } // Create a temporary folder var folder = DriveApp.createFolder('TempFolder'); // Fetch and resize images var images = []; for (var i = 0; i < imageUrls.length; i++) { var imageUrl = imageUrls[i]; var imageBlob = UrlFetchApp.fetch(imageUrl).getBlob(); var resizedBlob = resizeImage(imageBlob, 200, 200); // Adjust the width and height as needed var imageFile = folder.createFile(resizedBlob); images.push(imageFile.getBlob()); } // Create a temporary sheet for PDF conversion var tempSheet = spreadsheet.insertSheet('TempSheet'); tempSheet.getRange(1, 1, data.length, data[0].length).setValues(data); // Insert resized images into the temporary sheet for (var i = 0; i < images.length; i++) { tempSheet.insertImage(images[i], 1, data.length + i + 1); // Adjust column index } // Convert the temporary sheet to PDF var pdf = folder.createFile(tempSheet.getAs('application/pdf').getBytes()); // Email the PDF to the user MailApp.sendEmail({ to: 'user@example.com', // Replace with the recipient's email address subject: 'PDF with Images', body: 'Please find the attached PDF.', attachments: [pdf] }); // Clean up: Delete the temporary folder and sheet folder.setTrashed(true); spreadsheet.deleteSheet(tempSheet); } function resizeImage(blob, width, height) { var base64 = Utilities.base64Encode(blob.getBytes()); var resizedBase64 = Utilities.base64EncodeWebSafe(Utilities.newBlob(Utilities.base64DecodeWebSafe(base64)).getResize(width, height).getBytes()); return Utilities.new

]]>
By: jmarkus https://spreadsheetpoint.com/insert-image-in-cell-google-sheets/#comment-13467 Fri, 02 Feb 2024 12:38:15 +0000 https://spreadsheetpoint.com/?p=931#comment-13467 In reply to Biha.

Maybe try a workaround? You could try fetching the images separately, resizing them, and then embedding them in the PDF. Here’s what an app script would look like for that:

function convertSheetToPDFAndEmail() {
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
var sheet = spreadsheet.getSheetByName('YourSheetName'); // Replace 'YourSheetName' with the actual sheet name
var range = sheet.getDataRange();
var data = range.getValues();
var urlColumnIndex = 1; // Adjust this to the column index where image URLs are located

// Fetch all image URLs
var imageUrls = [];
for (var i = 1; i < data.length; i++) { var imageUrl = data[i][urlColumnIndex - 1]; // Adjust to 0-based index imageUrls.push(imageUrl); } // Create a temporary folder var folder = DriveApp.createFolder('TempFolder'); // Fetch and resize images var images = []; for (var i = 0; i < imageUrls.length; i++) { var imageUrl = imageUrls[i]; var imageBlob = UrlFetchApp.fetch(imageUrl).getBlob(); var resizedBlob = resizeImage(imageBlob, 200, 200); // Adjust the width and height as needed var imageFile = folder.createFile(resizedBlob); images.push(imageFile.getBlob()); } // Create a temporary sheet for PDF conversion var tempSheet = spreadsheet.insertSheet('TempSheet'); tempSheet.getRange(1, 1, data.length, data[0].length).setValues(data); // Insert resized images into the temporary sheet for (var i = 0; i < images.length; i++) { tempSheet.insertImage(images[i], 1, urlColumnIndex + i); // Adjust column index } // Convert the temporary sheet to PDF var pdf = folder.createFile(tempSheet.getAs('application/pdf').getBytes()); // Email the PDF to the user MailApp.sendEmail({ to: 'user@example.com', // Replace with the recipient's email address subject: 'PDF with Images', body: 'Please find the attached PDF.', attachments: [pdf] }); // Clean up: Delete the temporary folder and sheet folder.setTrashed(true); spreadsheet.deleteSheet(tempSheet); } function resizeImage(blob, width, height) { var base64 = Utilities.base64Encode(blob.getBytes()); var resizedBase64 = Utilities.base64EncodeWebSafe(Utilities.newBlob(Utilities.base64DecodeWebSafe(base64)).getResize(width, height).getBytes()); return Utilities.newBlob(Utilities.base64DecodeWebSafe(resizedBase64)); }

]]>
By: jmarkus https://spreadsheetpoint.com/insert-image-in-cell-google-sheets/#comment-13466 Fri, 02 Feb 2024 12:37:09 +0000 https://spreadsheetpoint.com/?p=931#comment-13466 In reply to Javier.

Google Forms doesn’t provide a built-in feature to directly display images in the associated Google Sheets for responses. That said, you could use Google App Script to include them in the Google Sheets response workbook.

]]>
By: Tan https://spreadsheetpoint.com/insert-image-in-cell-google-sheets/#comment-11696 Wed, 28 Jun 2023 17:50:38 +0000 https://spreadsheetpoint.com/?p=931#comment-11696 I get an error for the Apps Script and it’s unknown so I have no idea what the problem is.

why did you use pictures when you could have just typed it out so others could copy/paste it into the field?

]]>
By: Chris Daniel https://spreadsheetpoint.com/insert-image-in-cell-google-sheets/#comment-11672 Fri, 23 Jun 2023 02:35:02 +0000 https://spreadsheetpoint.com/?p=931#comment-11672 In reply to Ashish Mundra.

Unfortunately, Google Sheets does not have the same functionality yet.

]]>
By: Claire https://spreadsheetpoint.com/insert-image-in-cell-google-sheets/#comment-11444 Mon, 15 May 2023 20:07:33 +0000 https://spreadsheetpoint.com/?p=931#comment-11444 Hello! Wonderful tips. Thank you!
I have just a problem with the AppScript. After all the eaxct steps, I see this error

ReferenceError: sheetRange is not defined

But I inserted exactly A1 and A5 as the script… Is there some workaround?
Thank you very much in advance.

]]>