我正在使用通過 Google 表單輸入的資料在 Google 表格的列中生成 QR 碼,我想將它們保存為影像。
我想在 Google Sheets 中連續生成 QR 碼,我想將它們保存為影像。我無法復制此功能生成的影像:
=image("https://image-charts.com/chart?chs=150x150&cht=qr&choe=UTF-8&chl="&ENCODEURL(B2))
使用 Ctrl C 和 Ctrl V 僅在 Google 表格內有效,而嘗試在表格外復制和粘貼該表格也無效。剪貼板被檢測為不包含要粘貼到其他位置的影像。
問題不在于生成 QR,而是將其作為影像匯出或保存到谷歌驅動器中的檔案夾。我希望命名為生成影像(二維碼)的鏈接,以及列名和行名,以確保影像是正確的二維碼圖片。
我認為這可以通過使用谷歌應用腳??本來完成
這是 樣品表 這是 檔案夾鏈接
uj5u.com熱心網友回復:
嘗試
function uploadFile() {
var sh = SpreadsheetApp.getActiveSheet()
var datas = sh.getRange('B2:B' sh.getLastRow()).getValues()
datas.forEach(function (data) {
if (data != '') {
var imgurl = "https://image-charts.com/chart?chs=150x150&cht=qr&choe=UTF-8&chl=" encodeURI(data)
var image = UrlFetchApp.fetch(imgurl).getBlob().getAs('image/jpeg').setName(data);
var folder = DriveApp.getFolderById('________your folder id_____');
var file = DriveApp.createFile(image);
Drive.Files.update({ "parents": [{ "id": folder.getId() }] }, file.getId());
}
})
}
啟用驅動器 api 并將您的檔案夾 ID 放入腳本中
或者,將復選框放在 A 列中并為此功能放置觸發器
function uploadQRCode(event) {
var s = event.source.getActiveSheet();
var r = event.source.getActiveRange();
if (s.getName() == "Sheet1" && r.getColumn() == 1 && r.getValue() == true) {
var imgurl = "https://image-charts.com/chart?chs=150x150&cht=qr&choe=UTF-8&chl=" encodeURI(r.offset(0,1).getValue())
var image = UrlFetchApp.fetch(imgurl).getBlob().getAs('image/jpeg').setName(r.offset(0,1).getValue());
var folder = DriveApp.getFolderById('________your folder id_____');
var file = DriveApp.createFile(image);
Drive.Files.update({"parents": [{"id": folder.getId()}]}, file.getId());
SpreadsheetApp.getActive().toast('QRCode "' r.offset(0,1).getValue() '" saved !')
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/419606.html
標籤:
下一篇:將3個谷歌電子表格同時匯入另一個
