So I'm trying to read an Excel file (.xlsx specifically) using the js-xlsx library shown here. I must have messed up somewhere with the installation, though, because I can't get access to the "XLSX" object that is necessary to do anything with the library.
Specifically, I tried adding a script with src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.10.5/xlsx.full.min.js" to my HTML page. When that didn't work, I installed the library manually with node and used src="js/node_modules/xlsx/dist/xlsx.full.min.js". Neither works; I'm still getting "The global variable 'XLSX' is not defined" whenever I try to use the library in my javascript.
I have a feeling I'm missing something basic, but I can't figure out what. What am I doing wrong?
Edit: Here's the code that I use to open the Excel file.
function handleDrop(e) {
e.stopPropagation();
e.preventDefault();
var files = e.dataTransfer.files;
var i,f;
alert("a");
for (i = 0; i != files.length; ++i) {
f = files[i];
var reader = new FileReader();
var name = f.name;
reader.onload = function(e) {
var data = e.target.result;
alert("b");
var workbook;
if(rABS) {
/* if binary string, read with type 'binary' */
workbook = XLSX.read(data, {type: 'binary'});
} else {
/* if array buffer, convert to base64 */
var arr = fixdata(data);
workbook = XLSX.read(btoa(arr), {type: 'base64'});
}
/*
* console.log(XLSX.utils.sheet_to_json(ws, {header:1}));
*/
alert("henlo world");
};
if(rABS) reader.readAsBinaryString(f);
else reader.readAsArrayBuffer(f);
}
}
None of the alerts go off, and the "XLSX" variable is marked as undeclared.