if i used XLSX plugin in my javascript code in “run javascript” tool workflow, then it throws the error.
XLSX is not defined.
Should I have to add any import statements for accessing XLSX library. If yes, then where and how i have to do this.
Here is the javascript code :
const uploaderDiv = document.getElementById('uploader');
const secondElementInsideUploader = uploaderDiv.children[1];
var files = secondElementInsideUploader.files;
const file = new Blob([secondElementInsideUploader.files[0]]);
var reader = new FileReader();
reader.readAsBinaryString(file);
reader.onload = function (e) {
var data = e.target.result;
var workbook = XLSX.read(data, {
type: "binary",
});
var result = {};
var firstSheetName = workbook.SheetNames[0];
var jsonData = XLSX.utils.sheet_to_json(
workbook.Sheets[firstSheetName]
);
alert(JSON.stringify(jsonData));
};
Actually yes, But my actual goat is to save the fields of spreadsheet in database.
I’ve used the workflow “Download data as CSV”, but it only accept csv files.
that’s why i’ve decided to use javascript for this. Is this right approach?