Add configurable date interpretation for formatted numeric cells#59
Merged
Nebu1eto merged 4 commits intoNebu1eto:mainfrom Apr 16, 2026
Merged
Conversation
…ader Microsoft Excel stores dates as `t="n"` number cells with a date number format attached, so the cell type alone never tells you whether a value is a date. This commit adds an opt-in way to surface those cells as `CellValue::Date` while keeping the default behavior spec-literal. - `DateInterpretation` enum on `OpenOptions` with two variants: `CellType` (default, spec-literal) and `NumFmt` (promote `t="n"` cells whose style points at a built-in date numFmt ID 14-22/45-47 or a custom format code containing date/time tokens). - `style::compute_style_is_date` helper that flattens the stylesheet's cellXfs into a per-index boolean lookup for cheap streaming checks. - `Workbook` stores the chosen interpretation; `open_sheet_reader` and `open_sheet_reader_owned` wire it plus the precomputed lookup into the stream readers. - Convert `SheetStreamReader::new` and `OwnedSheetStreamReader::new` to a builder-style API (`.row_limit(...)`, `.date_promotion(...)`), keeping only the truly required positional arguments and aligning with Rust conventions used elsewhere in the crate. The `s` attribute on `<c>` is now captured via `extract_cell_attrs`. - End-to-end tests build a workbook with mixed styled cells, round-trip it through save/open, and verify the interpretation for both policies.
Mirror the new core option in the Node binding and the TypeScript wrapper so JS consumers can opt into numFmt-based date promotion without juggling lower-level style APIs. - `JsOpenOptions.dateInterpretation?: string` accepted on all `open` entry points; mapped to the core enum (`"numFmt"` promotes, anything else falls back to `"cellType"`). - `OpenOptions.dateInterpretation?: 'cellType' | 'numFmt'` added to the high-level wrapper along with a named `DateInterpretation` type. - Regenerated `binding.d.ts` picks up the new field. - New `date-interpretation.spec.ts` exercises both modes end-to-end against a workbook with a mix of built-in, custom, and non-date styles.
Explain the OOXML ambiguity between `t="n"` and a date number format and describe the two interpretation modes with side-by-side Rust and TypeScript snippets. Added to both the English and Korean references.
Owner
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1b1d1b895b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Addresses P1 review comment: the option was only consumed by the streaming reader, so `Workbook::get_cell_value`, `get_rows` / `get_cols`, and their Node counterparts still returned different value types than the stream reader for the same file. - `Workbook::xml_cell_to_value` now honors `date_interpretation`: under `CellType` it skips the date-style promotion and returns `CellValue::Number`. - `row::get_rows` / `col::get_cols` (and `parse_cell_type_value` / `resolve_cell_value`) take a `style_is_date` lookup so the workbook drives date promotion consistently with the stream reader. - Default flipped from `CellType` to `NumFmt` so real-world Excel files (dates stored as `t="n"` + numFmt) read the way callers typically expect. Opt into `CellType` for spec-literal behavior. - New end-to-end tests assert both policies through `get_cell_value` and `get_rows` (stream-reader coverage kept). - Docs (en/ko) and the TS wrapper default updated.
Contributor
Author
|
All 3 read paths(stream, get_cell_value, get_rows/get_cols) now follow the new option. Default changed to |
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.
Thank you for your great work.
I've added an option that can handle date-formatted number cells. Those cells will be promoted to date type when
dateInterpretationis set to'numFmt'. Otherwise the behavior will remain the same.