fix: read XLS literal error cells as errors instead of booleans - #1011
Open
codeAnqiang-ma wants to merge 1 commit into
Open
fix: read XLS literal error cells as errors instead of booleans#1011codeAnqiang-ma wants to merge 1 commit into
codeAnqiang-ma wants to merge 1 commit into
Conversation
A BIFF BOOLERR record stores either a boolean or an error code, distinguished by its fError flag, but BoolErrRecordHandler called getBooleanValue() unconditionally. POI returns `errorCode != 0` for error records, so a literal #DIV/0! or #N/A read back as true and #NULL! (code 0) read back as false, while the same content stored in .xlsx read back as the error text. Branch on isError() and emit a CellDataTypeEnum.ERROR cell holding the error text, so the existing StringErrorConverter yields the same user-visible value as the xlsx path. This also lines the handler up with FormulaRecordHandler, which already maps XLS formula errors to ERROR. Assisted-by: Cursor (Fable 5) Co-authored-by: Cursor <cursoragent@cursor.com>
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.
Purpose of the pull request
Closed: #1010
What's changed?
A
.xlscell holding a literal error value — an error stored as the cell value rather than as a formula result, e.g. after "Paste Special → Values" — was read as a boolean, while the same content in.xlsxread correctly:.xlsbefore.xlsx#DIV/0!ERRORtrue#DIV/0!#N/AERRORtrue#N/A#NULL!ERRORfalse#NULL!A BIFF
BOOLERRrecord holds either a boolean or an error code (fErrorflag, exposed by POI asisBoolean()/isError()), butBoolErrRecordHandlercalledgetBooleanValue()unconditionally — POI returnserrorCode != 0for error records, so non-zero codes becametrueand#NULL!(code 0) becamefalse.The handler now branches on
isError()and emits aCellDataTypeEnum.ERRORcell carrying the error text, which the existingStringErrorConverterrenders as the value XLSX already produces. That matchesFormulaRecordHandler(XLS formula errors are alreadyERROR) andCellTagHandler(t="e"→ error text); the boolean branch is unchanged. The text comes fromErrorEval.getText(...), as in POI's ownDataFormatter.BoolErrRecordHandlerTestwrites that row to both formats and asserts they read back identically, inSTRINGandACTUAL_DATAmode.Test evidence: fails before the fix, passes after, no regressions
Before the fix (test present,
BoolErrRecordHandleratmain) — both cases fail:After the fix:
Full module suite and format check:
Run on JDK 21 (Temurin 21.0.5). I did not run the other JDKs of the CI matrix (8/11/17/25) locally; the change uses no version-specific API.
Checklist
Assisted-by: Cursor (Fable 5). I reproduced the behaviour locally and reviewed every line of this change and its test myself.