XLSX.read is not a function Electron JS
See original GitHub issueDears, I’m fairly new to this thing, so let me know what info I’m missing: VSCode Electron 11 Trying to read a local excel file in browser.
What I tried:
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.16.9/xlsx.core.min.js"></script>AND (not simultaneously)
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.16.9/xlsx.full.min.js"></script>What happened: I wrote the html file, and opened it in chrome (87.0 64bit, latest as of 2021-jan-03) It worked fine, reading alright. Then I npm-started the project in VSCode, and I got: “Uncaught TypeError: XLSX.read is not a function at FileReader.filereader.onload”
My Code Snippet:
`<script type="text/javascript">
let resultingJSON;
function selectFile()
{
let selectedFile;
document.getElementById('file').click();
document.getElementById('file').addEventListener('change', function (e)
{
selectedFile = e.target.files[0];
var fileReader = new FileReader();
fileReader.readAsBinaryString(selectedFile);
fileReader.onload = (event)=>
{
let data = event.target.result;
let workbook = XLSX.read(data,{type:"binary"});
let workSheet = workbook.Sheets["Sheet1"];
resultingJSON = XLSX.utils.sheet_to_json(workSheet);
}
});
}
</script>`
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:6 (3 by maintainers)
Top Results From Across the Web
How to use the xlsx.readFile function in xlsx - Snyk
it('should detect a sheet marked as a boxed context without result', function() { var workbook = XLSX.readFile(testDataFile2); var worksheet = workbook.Sheets[" ...
Read more >SheetJS read excel file, my file is not read - Stack Overflow
So I am trying to use the SheetJS javascript to read in some excel files. I download the SheetJS and I have copied...
Read more >Developers - XLSX.read is not a function Electron JS - - Bountysource
Dears, I'm fairly new to this thing, so let me know what info I'm missing: VSCode. Electron 11. Trying to read a local...
Read more >Electron 中XLSX.read is not a function 的原因 - 掘金
在XLSX 的Github 官网发现一个issue XLSX.read is not a function Electron JS · Issue #2209 · SheetJS/sheetjs,但是并没有解决问题。
Read more >Data Import | SheetJS Community Edition
Browsers generally do not allow reading files by specifying filename (it is a security risk), and running XLSX.readFile in the browser will throw...
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 Free
Top 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
if nodeIntegration = true,window.module is not undefined,xlsx use CommonJs, so window.XLSX = {}
there is source code from xlsx
maybe you can find an answer: https://juejin.cn/post/7006212507719172127/
Please try using the require form. You can see how the demo does it by using a script tag to reference the JS file and performing a require from the script