XLSX.writeFile not working in Electron #1994

Closed
opened 2020-06-11 05:21:37 +00:00 by ldsenow · 7 comments
ldsenow commented 2020-06-11 05:21:37 +00:00 (Migrated from github.com)

Hi there,

I am experiencing an issue which XLSX.writeFile(workbook, filename); is not working in Electron. There is no error but no file is being downloaded

Hi there, I am experiencing an issue which XLSX.writeFile(workbook, filename); is not working in Electron. There is no error but no file is being downloaded
SheetJSDev commented 2020-06-11 05:29:41 +00:00 (Migrated from github.com)

The electron demo calls showSaveDialog, so you might need to call it first and get a path that you can then write to.

If you are doing that and still finding an error, a similar issue was reported by @ianjennings in https://github.com/SheetJS/sheetjs/issues/1981 -- I believe the APIs were changed between 1.7.5 and now and you need to use showSaveDialogSync.

@ianjennings is the nodeIntegration parameter required for writing files?

The [electron demo](https://github.com/SheetJS/sheetjs/tree/master/demos/electron) calls `showSaveDialog`, so you might need to call it first and get a path that you can then write to. If you are doing that and still finding an error, a similar issue was reported by @ianjennings in https://github.com/SheetJS/sheetjs/issues/1981 -- I believe the APIs were changed between 1.7.5 and now and you need to use `showSaveDialogSync`. @ianjennings is the `nodeIntegration` parameter required for writing files?
ldsenow commented 2020-06-11 05:45:30 +00:00 (Migrated from github.com)

showSaveDialogSync works. However, I dont want to introduce electron specific api in the code base. Ideally, if the lib can detect the environment and handles internally

showSaveDialogSync works. However, I dont want to introduce electron specific api in the code base. Ideally, if the lib can detect the environment and handles internally
SheetJSDev commented 2020-06-11 05:53:07 +00:00 (Migrated from github.com)

That's fair, the library already does some environment checking in writeFile. We'd have to implement some ideas from https://github.com/electron/electron/issues/2288 to test where we are running in electron (main or renderer process)

That's fair, the library already does some environment checking in writeFile. We'd have to implement some ideas from https://github.com/electron/electron/issues/2288 to test where we are running in electron (main or renderer process)
ldsenow commented 2020-06-11 05:55:41 +00:00 (Migrated from github.com)

Thanks for the prompt reply, meanwhile, I put a note in the code base and come back to it once a new version released.

Thanks for the prompt reply, meanwhile, I put a note in the code base and come back to it once a new version released.
shaikarifrizwan commented 2020-06-19 16:17:37 +00:00 (Migrated from github.com)

@ldsenow Could you please share how did you work it out, i'm also trying to create new workbook and and save in my path 'D:\out.xlsx' with array of json objects.

@ldsenow Could you please share how did you work it out, i'm also trying to create new workbook and and save in my path 'D:\\out.xlsx' with array of json objects.
ldsenow commented 2020-06-22 00:03:32 +00:00 (Migrated from github.com)

@shaikarifrizwan I use Quasar which gives me the platform detection. https://quasar.dev/options/platform-detection

If you like you could go and check out their source code how to detect the platform. I assume it is gonna be whole bunch of string pattern matching.

@shaikarifrizwan I use Quasar which gives me the platform detection. https://quasar.dev/options/platform-detection If you like you could go and check out their source code how to detect the platform. I assume it is gonna be whole bunch of string pattern matching.
srijonsaha commented 2020-06-26 08:18:56 +00:00 (Migrated from github.com)

Hi. XLSX.writeFile works when tested using the main and renderer processes in Electron. The current Electron demo is broken due to API changes in showSaveDialog and is being fixed in this PR #2027. Please refer to the demo on proper usage for Electron.

Hi. `XLSX.writeFile` works when tested using the main and renderer processes in Electron. The current Electron demo is broken due to API changes in `showSaveDialog` and is being fixed in this PR #2027. Please refer to the demo on proper usage for Electron.
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: sheetjs/sheetjs#1994
No description provided.