These two days encounter big problem, is this xlsx import problem, before with Xlsx.full.min.js, write the import, the result is incompatible with IE browser, study this also good long time, on-line incredibly still did not search the suitable, oneself write from the xlsx official online to find a big example, changed the change,
In the introduction
Shim.js Jszip.js Xlsx.js
On the basis of
On the code:
var X = XLSX;
var RABS = false;
var process_wb = function PROCESS_WB (WB) {
var result = {};
Wb. Sheetnames.foreach (function (sheetname) {
var roa = X.utils.sheet_to_json (WB). Sheets[sheetname], {
Header:1
});
if (roa.length) result[sheetname] = Roa;
});
var output = json.stringify (result, 2, 2);
Console.log (Json.parse (output));
document.write (output);
};
var do_file = function Do_file (files) {
var f = files[0];
var reader = new FileReader ();
Reader.onload = function (e) {
if (typeof console!== ' undefined ') console.log ("onload", New Date (), RABS);
var data = E.target.result;
if (!rabs) {
data = new Uint8array (data)
}
PROCESS_WB (X.read (data, {
Type:rabs? ' binary ': ' array '
}));
};
if (RABS) {
Reader.readasbinarystring (f);
}else{
Reader.readasarraybuffer (f);
}
};
(function () {
var xlf = document.getElementById (' Xlf ');
if (!xlf.addeventlistener) return;
function Handlefile (e) {
Console.log (E.target.files);
Get to File
Do_file (E.target.files);
}
Xlf.addeventlistener (' Change ', Handlefile, false);
})();
Github:https://github.com/jialianbao/xlsx-import
XLSX Import into--json