SheetJS / sheetjs

📗 SheetJS Spreadsheet Data Toolkit -- New home https://git.sheetjs.com/SheetJS/sheetjs
https://sheetjs.com/
Apache License 2.0
35.14k stars 8k forks source link

TypeError: _fs is undefined [Tried xlsx.js, xlsx.full.min.js, xlsx.core.min.js] #330

Closed SentientBits closed 7 years ago

SentientBits commented 8 years ago

I have tried every combination I can think of yet I still get _TypeError: fs is undefined. Attached is the HTML file with embedded script.

Am I missing something??

index.txt

Full Stack Trace TypeError: _fs is undefined readSync()xlsx.full.min.js (line 18) readFileSync()xlsx.full.min.js (line 18) index.html()index.html (line 24) n.event.dispatch()jquery.min.js (line 3) n.event.add/r.handle()jquery.min.js (line 3)

piotrblasiak commented 8 years ago

I get this as well - any news on this?

garrett92895 commented 8 years ago

I'm having issues with this as well. Looking through the code, it appears that js-xlsx relies on Node's fs module. I'm not sure how that works (I'm fairly new to all of this), but I'm working on figuring out how to either pull in the fs module as a dependency or create my own wrapper that uses javascript's FileReader underneath (worst case scenario)

jacaseyclyde commented 8 years ago

Also running into issues with this. If anyone figures out a good workaround, I'd love to know (and will likewise comment here I figure something out)

oscarfonts commented 7 years ago

Look at #285

SheetJSDev commented 7 years ago

You can't use fs or XLSX.readFile in the browser. Use XLSX.read. If you need specific examples, the demo http://oss.sheetjs.com/js-xlsx/ source is in the gh-pages branch of the repo. index.html uses HTML5 File API and ajax.html uses XMLHttpRequest