1// i use the vue template
2<input type="file" @change="handleChange" />
3handleChange(e) {
4 this.file = e.target.files[0]
5},
6handleImport() {
7 const wb = new Excel.Workbook();
8 const reader = new FileReader()
9
10 reader.readAsArrayBuffer(this.file)
11 reader.onload = () => {
12 const buffer = reader.result;
13 wb.xlsx.load(buffer).then(workbook => {
14 console.log(workbook, 'workbook instance')
15 workbook.eachSheet((sheet, id) => {
16 sheet.eachRow((row, rowIndex) => {
17 console.log(row.values, rowIndex)
18 })
19 })
20 })
21 }
22}
1var workbook = new Excel.Workbook();
2workbook.xlsx.readFile(filename)
3 .then(function() {
4 var worksheet = workbook.getWorksheet(sheet);
5 worksheet.eachRow({ includeEmpty: true }, function(row, rowNumber) {
6 console.log("Row " + rowNumber + " = " + JSON.stringify(row.values));
7 });
8});