Reputation: 21
I have a Google Sheets sheet that creates QR images from the Google charts API using the IMAGE function that takes a URL to encode as an argument. I would like to export the created images to an image file, say a JPG. Problem is Sheets does not recognize the cell content as an image so SHIFT + Right click does not show the Save Image As in the context menu. Any ideas on how to export all of these to separate files.
Upvotes: 2
Views: 4166
Reputation: 776
Download the sheet in Microsoft Excel .xlsx format by going to the File > Download menu.
Then open the .xlsx file in your computer using any unzip program (e.g. 7z) and navigate to ../xl/media in the zip file. All the images would be there - extract where you want them.
Upvotes: 4
Reputation: 1610
This will fit your needs:
Look at the folder.
The script:
function isImageToImage(){
const ss = SpreadsheetApp.getActiveSpreadsheet();
const sheet = ss.getSheetByName('Data');
const formulas = sheet.getRange(2,1, sheet.getLastRow()-1).getFormulas().flat();
const urls = formulas.map(formula => {
return /\"(.*?)\"/gmi.exec(formula)[1]
})
const folder = DriveApp.getFolderById('1QVo_pr_Wo6xxxxxxxxx9Yx')
urls.forEach(url => {
console.log(url)
const blob = UrlFetchApp.fetch(url).getBlob();
folder.createFile(blob)
})
}
Upvotes: 3