XLSX with web-worker using react #3064
Labels
No Label
DBF
Dates
Defined Names
Features
Formula
HTML
Images
Infrastructure
Integration
International
ODS
Operations
Performance
PivotTables
Pro
Protection
Read Bug
SSF
SYLK
Style
Write Bug
good first issue
No Milestone
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: sheetjs/sheetjs#3064
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Hi Im working on react project bootstrapped by webpack-5 . There is one button in component on click of that button we are calling an api which result array of objects and once we get result with the help of XLSX we are converting them into excel file and downloading it . This functionality works perfectly fine . but due blocking of main thread UI gets freeze/hand and once it complete then all UI work fine .
Now I'm trying to off load excel conversion to the worker for that I've created one file called excelWorker.ts
and in that file Im calling that excel conversion function .as function need XLSX dependency so that in same file i have imported XLSX .like this way import * as XLSX from "xlsx";
my worker code look like this
As some how my react throwing error that it is unable to understand this line import * as XLSX from "xlsx";
My worker js code completely works fine when I perform simple task like addition , sorting and filtering which does not depend on XLSX but the task which requird XLSX is not working .
Could you please help me how can I make use of XLSX in worker file .or any example for reference .
https://docs.sheetjs.com/docs/demos/bigdata/worker examples.
Your error suggests webpack isn't bundling the worker script. The simplest solution is to use
importScripts
and point to the standalone build (https://docs.sheetjs.com/docs/getting-started/installation/standalone#web-workers)Also note that
writeFile
will not work from a web worker. See the "Creating a Local File" example for a workaround where file data is written in the worker and sent back to the main thread for download.