I need to read the excel sheet data from magento 2.4 javascript file. I have overridden Magento_Sales/web/order/create/scripts.js. I can read csv file data without any issue but can’t read excel file data. How can I use the following script and code in my js function. I found this in https://stackoverflow.com/a/37083658/6841988
<script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.8.0/xlsx.js"></script>
<script>
var ExcelToJSON = function() {
this.parseExcel = function(file) {
var reader = new FileReader();
reader.onload = function(e) {
var data = e.target.result;
var workbook = XLSX.read(data, {
type: 'binary'
});
workbook.SheetNames.forEach(function(sheetName) {
// Here is your object
var XL_row_object = XLSX.utils.sheet_to_row_object_array(workbook.Sheets[sheetName]);
var json_object = JSON.stringify(XL_row_object);
console.log(json_object);
})
};
reader.onerror = function(ex) {
console.log(ex);
};
reader.readAsBinaryString(file);
};
};
</script>
I just need to know how to import this script in my js and use it just like in the above code.