-
-
Notifications
You must be signed in to change notification settings - Fork 8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
XLSX.read is not a function Electron JS #2209
Comments
Be sure that XSLX library loads before your main script. ...and i think you don't need both And also check paths for scripts in electron. I'm developing some electron-app with this lib and sometimes i fed up with paths =) |
Overall, electron pretends to be node-like both in the main thread and the renderer thread. This presents issues with the standalone scripts. In the |
if nodeIntegration = true,window.module is not undefined,xlsx use CommonJs, so window.XLSX = {} there is source code from xlsx if(typeof exports !== 'undefined') make_xlsx_lib(exports);
else if(typeof module !== 'undefined' && module.exports) make_xlsx_lib(module.exports);
else if(typeof define === 'function' && define.amd) define(function() { if(!XLSX.version) make_xlsx_lib(XLSX); return XLSX; });
else make_xlsx_lib(XLSX); maybe you can find an answer: https://juejin.cn/post/7006212507719172127/ |
@fujinxiang Does the demo project work for you? The required arguments for electron 14 are: win = new electron.BrowserWindow({
width: 800, height: 600,
webPreferences: {
worldSafeExecuteJavaScript: true, // required for Electron 12+
contextIsolation: false, // required for Electron 12+
nodeIntegration: true,
enableRemoteModule: true
}
}); With that, |
i have not try the demo, i use xlsx in script tag, not require, and the electron version of my application is 4.x.x. |
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 |
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 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">
The text was updated successfully, but these errors were encountered: