Skip to content

Add configurable date interpretation for formatted numeric cells#59

Merged
Nebu1eto merged 4 commits intoNebu1eto:mainfrom
potados99:feat/date-interpretation-option
Apr 16, 2026
Merged

Add configurable date interpretation for formatted numeric cells#59
Nebu1eto merged 4 commits intoNebu1eto:mainfrom
potados99:feat/date-interpretation-option

Conversation

@potados99
Copy link
Copy Markdown
Contributor

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 dateInterpretation is set to 'numFmt'. Otherwise the behavior will remain the same.

…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.
@Nebu1eto
Copy link
Copy Markdown
Owner

@codex

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread crates/sheetkit-core/src/workbook/mod.rs
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.
@potados99
Copy link
Copy Markdown
Contributor Author

All 3 read paths(stream, get_cell_value, get_rows/get_cols) now follow the new option. Default changed to 'numFmt'.

@Nebu1eto Nebu1eto changed the title Feat/date interpretation option Add configurable date interpretation for formatted numeric cells Apr 16, 2026
Copy link
Copy Markdown
Owner

@Nebu1eto Nebu1eto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@Nebu1eto Nebu1eto merged commit 48002c7 into Nebu1eto:main Apr 16, 2026
2 of 3 checks passed
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.

2 participants