1
votes

[This is what I have]

1I am having the candidate names in A2 column. I am creating QR code for all the names in B2 column using this formula :

=image("https://api.qrserver.com/v1/create-qr-code/?size=300x300&data="&encodeurl(A2))

I have around 500 names and their respective QR codes in both columns. Now I want to save all that QR codes as an image file(PNG/JPEG) to a folder in Google Drive with their respective names. Can anyone help me with the google app script?

I have searched a lot but all I can get is some complex scripts which I can't convert to what I need!

Thanks in advance!

1

1 Answers

5
votes

You do not even need to insert the QR codes into your sheet

Instead you can directly fetch them with the UrlFetchApp and save on your Drive with a simple script.

Sample:

function myFunction() {
  var sheet = SpreadsheetApp.getActive().getActiveSheet();
  var data = sheet.getRange("A2:A" + sheet.getLastRow()).getValues().flat();
  for (var i = 0; i < data.length; i++){
    var url = "https://api.qrserver.com/v1/create-qr-code/?size=300x300&data="+encodeURIComponent(data[i]);
    var blob = UrlFetchApp.fetch(url).getBlob();
    DriveApp.createFile(blob).setName(data[i]);
  }
}