How to use JS libraries in Google Sheet App Script?

拟墨画扇 提交于 2020-06-28 04:58:28

问题


I want to write a custom function in Google Sheet to generate barcodes. How do I import external js libraries (e.g. https://lindell.me/JsBarcode/)?

This is what have I so far:

function genBarcode(input) {
  var url = "https://cdn.jsdelivr.net/jsbarcode/3.6.0/JsBarcode.all.min.js";
  var js = UrlFetchApp.fetch(url).getContentText();
  eval(js);
  // I want to do something like this
  // return JsBarcode("#barcode", "Hi world!");
  // But Google sheet says JsBarcode is undefine. 
}

来源:https://stackoverflow.com/questions/52528295/how-to-use-js-libraries-in-google-sheet-app-script

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!