question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

when using XLSX.read(),there is an error "Uncaught TypeError: Cannot read property 'read' of undefined",need help

See original GitHub issue

when 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:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

7reactions
pferreirafabriciocommented, Jun 18, 2022

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:

[Vue warn]: Error in v-on handler: "TypeError: Cannot read properties of undefined (reading 'utils')"

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'

7reactions
digelimcommented, Jun 8, 2016

Try replacing this line: //if(typeof require !== ‘undefined’) XLSX = require(‘xlsx’); to this: XLSX = require(‘xlsx’);

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found