Skip to content

Apply date and time number formats only to numeric cells - #1042

Merged
michelebastione merged 1 commit into
mini-software:v1.x-maintenancefrom
pedrorossato:fix/text-cell-date-format
Nov 12, 2026
Merged

michelebastione merged 1 commit into
mini-software:v1.x-maintenancefrom
pedrorossato:fix/text-cell-date-format

Conversation

@pedrorossato

Copy link
Copy Markdown
Contributor

Fixes #1041

ConvertValueByStyleFormat converted any value whose text parsed as a double, so text cells (t="s", t="str" and t="inlineStr") with a date or time number format came back as DateTime/TimeSpan, with a result that depended on the current culture. ConvertCellValue yields a double only for numeric cells, so the method now returns any other value unchanged and converts the double directly.

  • ExcelOpenXmlStyles.ConvertValueByStyleFormat: early return for values that are not a double. The double is used as is, instead of going through double.TryParse(value?.ToString(), ...).
  • MiniExcelIssueTests.QueryReturnsTextCellsWithDateOrTimeFormatAsString: one row with a numeric cell and t="s", t="str" and t="inlineStr" cells sharing a date format, plus a numeric cell and a t="s" cell sharing a time format. The numeric cells still come back as DateTime/TimeSpan and the text cells as string. It fails without the fix.
  • Helpers.ReplaceSharedStringsXml: test helper mirroring ReplaceStylesXml.

MiniExcelTests passes locally (381/381, net10.0, Windows). This machine only has the .NET 10 SDK, so it ran with -p:TargetFrameworks=net10.0 -p:LangVersion=preview.

Text cells (t="s", "str" and "inlineStr") with a date or time number
format were converted to DateTime/TimeSpan whenever their text parsed as
a double, with a result that depended on the current culture. Excel
never applies a number format to text.

ConvertCellValue yields a double only for numeric cells, so
ConvertValueByStyleFormat now returns any other value unchanged and
converts the double directly instead of round-tripping it through
ToString and double.TryParse.

Fixes mini-software#1041
@coderabbitai

coderabbitai Bot commented Nov 12, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: bc1b8e85-d142-4d52-8750-74b1e1f1110d

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@michelebastione
michelebastione merged commit e0cf1b2 into mini-software:v1.x-maintenance Nov 12, 2026
4 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