when using XLSX.read(),there is an error "Uncaught TypeError: Cannot read property 'read' of undefined",need help
See original GitHub issuewhen using XLSX.read(),there is an error “Uncaught TypeError: Cannot read property ‘read’ of undefined”, the code is below ,and i use meteor to develop
Template.codein.events({ ‘click #stock_save_id’:function(){ var filelist = document.getElementById(“stockfile_id”); //if(typeof require !== ‘undefined’) XLSX = require(‘xlsx’); if (filelist.files.length > 0) { for (i=0;i<filelist.files.length;i++) { var reader = new FileReader();
reader.onload = function(e) {
// 这个事件在读取成功结束后触发
if (e.error)
{
swal("error is "+e.error);
}
else
{
var xlsrow = e.target.result;
alert(xlsrow);
var workbook = XLSX.read(xlsrow, {type: 'binary'});
//var workbook = XLSX.read(xlsrow);
alert("over");
}
};
reader.readAsBinaryString(filelist.files[i]);
//reader.readAsDataURL(filelist.files[i]);
}
}
},
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:7 (2 by maintainers)
Top Results From Across the Web
I export my data to Excel but i get this error: Cannot read ...
I was importing the lib on a component with import XLSX from ... [Vue warn]: Error in v-on handler: "TypeError: Cannot read properties...
Read more >Cannot read properties of null (reading 'contentType')
I'm trying to load files into this library via ExcelUtility.load(file), where `file` is an xlsx file. The application crashes and the following ...
Read more >Cannot read properties of undefined' - JavaScript Debugging
How To Fix ' Uncaught TypeError : Cannot read properties of undefined' ... Do you make music and want to let me use...
Read more >Solved: Read excel data/links in javascript test complete
Solved: Hi team, I have tried to read the data file using javascript in test complete.But shows error as "Type error: cannot read...
Read more >TypeError: Cannot read properties of null (reading 'location')
After upgrading to rome the issue got created. There is an excel link(download) in the catalog item.When the user clicks it an excel...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I had a similar issue with the XLSX on Vue.js.
I was importing the lib on a component with
import XLSX from 'xlsx'
and getting this error on the console:And then I noticed on the terminal (which was running the vue.js app) the message:
"export 'default' (imported as 'XLSX') was not found in 'xlsx'
So I’ve resolved it by changing the import to:
import * as XLSX from 'xlsx'
Try replacing this line: //if(typeof require !== ‘undefined’) XLSX = require(‘xlsx’); to this: XLSX = require(‘xlsx’);