Skip to content

fix(xlsx): 修复 LuckyExcel 解析数据校验时 matchType 未映射导致的崩溃#730

Open
lanwood wants to merge 1 commit intokekingcn:masterfrom
lanwood:master
Open

fix(xlsx): 修复 LuckyExcel 解析数据校验时 matchType 未映射导致的崩溃#730
lanwood wants to merge 1 commit intokekingcn:masterfrom
lanwood:master

Conversation

@lanwood
Copy link
Copy Markdown

@lanwood lanwood commented Apr 10, 2026

问题

在 Excel(xlsx)在线预览使用 luckyexcel.umd.js 解析时,部分工作表包含 数据有效性(dataValidation),且类型经 DATA_VERIFICATION_MAP 映射后得到的 matchType(如 dropdowncheckbox 等)不在 DATA_VERIFICATION_TYPE2_MAP 中。原实现直接执行:

DATA_VERIFICATION_TYPE2_MAP[matchType][operator]

DATA_VERIFICATION_TYPE2_MAP[matchType]undefined 时,再访问 [operator](例如 between)会抛出:

TypeError: Cannot read properties of undefined (reading 'between')

现象:
e539316e23531003f13c956aa98d1a27

堆栈:LuckySheet.generateConfigDataValidationsnew LuckySheetLuckyFile.Parse

修复

generateConfigDataValidations 中先取 var _t2map = DATA_VERIFICATION_TYPE2_MAP[matchType],仅在 _t2map 存在且包含对应 operator 时使用映射值;否则与原先「无合法映射」时的行为一致,回退为 "bw"(与原分支在 operator 为空时使用 "bw" 的语义对齐)。

变更范围

  • server/src/main/resources/static/xlsx/luckyexcel.umd.js

测试文件:
luckyexcel-datavalidation-bug.xlsx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant