Optimize LuckyExcel xlsx preview conversion with Web Worker#766
Open
SpencerZhang wants to merge 1 commit into
Open
Optimize LuckyExcel xlsx preview conversion with Web Worker#766SpencerZhang wants to merge 1 commit into
SpencerZhang wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When previewing large xlsx files, LuckyExcel performs Excel parsing and conversion on the main thread. For files with many shared strings, styles, or sheets, Chrome can report warnings such as:
[Violation] 'setTimeout' handler took xxxxmsThe existing code wraps
LuckyExcel.transformExcelToLuckyByUrlinsetTimeout, but this only delays execution. The conversion still runs synchronously on the main thread and can block page interaction and loading UI updates.There is also a debug log in
luckyexcel.umd.js:console.log(allFileOption, 'allFileOption')For large files,
allFileOptionmay contain huge structures such assharedStrings, which makes DevTools logging slower and increases perceived loading cost.Solution
This change moves LuckyExcel xlsx conversion into a Web Worker:
xlsx/luckyexcel-worker.jsluckyexcel.umd.jsinside the worker withimportScriptsLuckyExcel.transformExcelToLuckyByUrlin the workerexportJsonback to the main threadluckysheet.createon the main thread, since DOM rendering must remain thereallFileOptiondebug logNotes
This reduces main-thread blocking during Excel parsing/conversion. Very large files may still spend time in
luckysheet.create, because rendering must happen on the main thread.Verification
git diff --checknode --check server/src/main/resources/static/xlsx/luckyexcel-worker.jsmvn -s <temporary-aspose-settings> -U clean package -Dmaven.test.skip=truewith JDK 21 generatedserver/target/kkFileView-5.0.0.tar.gz