问题描述:

I want to read the data of a specific xlsx file into javascript to show them on a .html page.

For that i downloaded sheetjs. A .xlsx parser.

But now I realized that you kinda must choose a file in the html site to read it. But I only want to use one file the whole time. Also the html site will only run local. So is there any way to get going with setting up a absolute path in the js to the file. So something like

file= "C:\test.xlsx"

Code example from the documemtary:

function handleFile(e) {

var files = e.target.files;

var i,f;

for (i = 0, f = files[i]; i != files.length; ++i) {

var reader = new FileReader();

var name = f.name;

reader.onload = function(e) {

var data = e.target.result;

var workbook = XLSX.read(data, {type: 'binary'});

/* DO SOMETHING WITH workbook HERE */

};

reader.readAsBinaryString(f);

}

}

input_dom_element.addEventListener('change', handleFile, false);

相关阅读:
Top