Skip to content

ODS import: error cells open as errors - #4373

Open
Hamza0101 wants to merge 1 commit into
storytold:mainfrom
Hamza0101:fix/ods-typed-error-values
Open

Hamza0101 wants to merge 1 commit into
storytold:mainfrom
Hamza0101:fix/ods-typed-error-values

Conversation

@Hamza0101

@Hamza0101 Hamza0101 commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #4301

What was wrong

The ODS reader in crates/xlsx/src/ods.rs recognised a cell's error type when it read the attributes, but convert had no case for it. The value fell back to the cell's displayed text, with the generic "unsupported values" warning. So a typed error cell (office:value-type="error", no formula) opened as the string #DIV/0!, and ISERROR on it was FALSE, where Excel reads it as an error, as the issue shows. The issue says a formula's cached error (calcext:value-type="error") lost its error type the same way.

What changed

  • An error cell's code is read from its office:string-value, or else its displayed text. It becomes the matching error value through CellError::parse, ignoring case and surrounding spaces.
  • What stays text: a code Excel has no error for, such as LibreOffice's Err:502 (still reported as unsupported); and a cell typed string that merely reads like an error.
  • A changed test expectation: ods_extension_error_cache_never_imports_its_placeholder_zero checks that a cached error never imports as the placeholder office:value="0" written beside it. That still holds. It previously expected the text #DIV/0! (the fallback then), and now expects the #DIV/0! error itself, which is what ODS import turns typed error values into text #4301 asks for. So it's updated, with a comment.

QA report

Main vs branch, end to end (gridcraft-cli, an ODS file)

err.ods is a minimal ODS package I assembled. Its cells:

  • A1 the issue's typed error (office:value-type="error" office:string-value="#DIV/0!");
  • B1 plain text;
  • C1 an Excel-style formula of:=1/0 with calcext:value-type="error" and a placeholder office:value="0";
  • D1 a typed error whose code is only in its text, #N/A;
  • E1 a string cell whose text is #DIV/0!;
  • F1 the float 7.

Each build converted it to .xlsx (run --in err.ods --out out.xlsx), and I evaluated these formulas on the result. main is a gridcraft-cli built from origin/main (abcfc191); the branch is this PR (900f79ee). The Excel column is the issue's result; I didn't run Excel myself.

Formula main this PR Excel (issue)
=ISERROR(A1) (typed error) FALSE TRUE TRUE
=ISERROR(B1) (plain text) FALSE FALSE FALSE
=ISERROR(C1) (formula's cached error) FALSE TRUE "the same loss also occurs"
=ISERROR(D1) (#N/A in the text) FALSE TRUE
=IFERROR(ERROR.TYPE(A1),"-") / =IFERROR(ERROR.TYPE(D1),"-") - / - 2 / 7
=ISERROR(E1) / =ISTEXT(E1) (string reading #DIV/0!) FALSE / TRUE FALSE / TRUE
=F1 7 7
"unsupported values" warning yes no

Tests

tests::ods_tests::ods_error_cells_open_as_errors covers:

  • the issue's typed error and its plain-text neighbour;
  • a formula's cached error, and #N/A read from the cell's text;
  • #value! with spaces, read as #VALUE!;
  • a string cell reading #DIV/0!, which stays text;
  • Err:502, which stays text and is still reported.

ods_extension_error_cache_never_imports_its_placeholder_zero now expects the error rather than its text, as explained above. The other ODS tests still pass.

Negative control

With the error case disabled (on top of 900f79ee, then restored with git checkout), the new test fails at A1: left Text("#DIV/0!"), right Error(Div0).

Gate (macOS arm64)

Step Result
cargo fmt --all -- --check clean
cargo clippy -p gridcraft-xlsx --all-targets -- -D warnings clean
cargo test -p gridcraft-xlsx -p gridcraft-engine 1004 (+1 ignored) + 120 + 7 + 375 passed, 0 failed

Not covered

  • LibreOffice's own error codes (Err:502 and the like) stay text. Mapping them to Excel errors would be a separate decision.
  • Overlap with ODS: formulas, formatting and export #1575: that PR imports ODS formulas and handles errors for the formulas it imports. This change is data-only and also covers cells with no formula, as the issue notes. If both land, a formula cell's value comes from whichever path runs.
  • Overlap with ODS import: a date at 24:00:00 is the next midnight #4371 and ODS import: durations with zero years and months are read #4372: they edit parse_date and parse_duration in the same file; this edits convert and the attribute key. Their tests sit in different places.
  • Excel: the Excel column is the issue's results; I didn't run Excel myself.
  • cargo xtask ci: I didn't run the full cargo xtask ci (wasm, layers, the other crates).

Summary by CodeRabbit

  • Bug Fixes
    • ODS error cells and cached formula errors with recognized Excel error codes now open as errors instead of text.
    • Unsupported error codes and string cells containing error-like text remain text; unsupported codes continue to generate a warning.

A cell typed office:value-type="error", or a formula whose cached result is an error (calcext:value-type="error"), opened as the text of its code, so ISERROR said FALSE and the "unsupported values" warning appeared. Its code (the string value, or the cell's text) now becomes the error. A code Excel has no error for (Err:502) stays text, and a string cell that reads like an error stays a string. Fixes storytold#4301.
@coderabbitai

coderabbitai Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The ODS reader now imports recognized typed error cells and cached formula errors as cell errors. Unsupported error codes and ordinary strings remain text. Tests cover recognized codes, fallback behavior, and cached formula errors.

Changes: ODS error import

Layer / File(s) Summary
Error value conversion and validation
crates/xlsx/src/ods.rs, crates/xlsx/src/tests/ods_tests.rs
The reader uses string-value for string and error cells. It parses recognized error codes from nonblank raw values, or displayed text when needed. Unsupported codes remain text. Tests cover typed errors, cached formula errors, ordinary strings, and unsupported codes.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Possibly related issues

  • Issue 711: The change converts cached formula errors to error values, which addresses part of the issue. Formula import is not changed.

Suggested reviewers: harrisonoconnorhover, dylanmtaylor

Merge Risk: Minimal · up to 900f7

ODS error cells now open as real errors, so ISERROR can distinguish them from ordinary text. Unrecognized codes and string cells that merely resemble errors remain text. No merge-blocking risk is identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "ODS import: error cells open as errors" matches the main change. The PR makes ODS error cells, including cached formula errors, import as Value::Error instead of text. The title is specific…
Linked Issues check Passed Issue #4301 requires that ODS typed error cells (office:value-type="error", no formula) import as errors, that cached formula errors (calcext:value-type="error") keep their error type, and that or…
Out of Scope Changes check Passed The whole-PR diff against the merge base changes one source file, crates/xlsx/src/ods.rs, in the ODS value conversion and attribute key selection, plus test updates in `crates/xlsx/src/tests/ods_tes…
Full details: Title check

Explanation

The title "ODS import: error cells open as errors" matches the main change. The PR makes ODS error cells, including cached formula errors, import as Value::Error instead of text. The title is specific and concise, and it names the format and the behavior. The changes in ods.rs and ods_tests.rs align with this description.

Full details: Linked Issues check

Explanation

Issue #4301 requires that ODS typed error cells (office:value-type="error", no formula) import as errors, that cached formula errors (calcext:value-type="error") keep their error type, and that ordinary text stays text. The diff in crates/xlsx/src/ods.rs adds a Some("error") arm to the value conversion. The arm passes the office:string-value, or the displayed text when that is blank, to CellError::parse and maps a match to Value::Error. The attribute lookup now reads string-value for error cells, so the code is found. Plain text cells follow the unchanged None arm and stay text. Codes with no Excel error, such as Err:502, return no value and keep the existing unsupported-value fallback. The string value type is unchanged. The test changes cover the typed error, the cached formula error, the text-only #N/A code, whitespace handling, the string cell that reads as an error, and Err:502. I did not run the tests. The test results rely on the PR author's report. The requirement to map the code is implemented in source at the reviewed head.

Full details: Out of Scope Changes check

Explanation

The whole-PR diff against the merge base changes one source file, crates/xlsx/src/ods.rs, in the ODS value conversion and attribute key selection, plus test updates in crates/xlsx/src/tests/ods_tests.rs. All source changes map directly to #4301: the error attribute key, the new error conversion arm, and the comment. The updated placeholder-zero test expects the error value that the issue requests. No unrelated refactoring or feature work appears in the summary. I did not inspect the test file hunks directly.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between abcfc19 and 900f79e.

Files selected for processing: 2

  • crates/xlsx/src/ods.rs
  • crates/xlsx/src/tests/ods_tests.rs

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 0 remain after this review.

emrahoksak pushed a commit to emrahoksak/girdcraft- that referenced this pull request Nov 18, 2026

This branch has not been deployed

No deployments
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.

ODS import turns typed error values into text

1 participant