Repository navigation
Apply date and time number formats only to numeric cells - #1042
Merged
michelebastione merged 1 commit intoNov 12, 2026
Merged
michelebastione merged 1 commit into
michelebastione merged 1 commit into
Conversation
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
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
michelebastione
merged commit Nov 12, 2026
e0cf1b2
into
mini-software:v1.x-maintenance
4 checks passed
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.
Fixes #1041
ConvertValueByStyleFormatconverted any value whose text parsed as adouble, so text cells (t="s",t="str"andt="inlineStr") with a date or time number format came back asDateTime/TimeSpan, with a result that depended on the current culture.ConvertCellValueyields adoubleonly for numeric cells, so the method now returns any other value unchanged and converts thedoubledirectly.ExcelOpenXmlStyles.ConvertValueByStyleFormat: early return for values that are not adouble. Thedoubleis used as is, instead of going throughdouble.TryParse(value?.ToString(), ...).MiniExcelIssueTests.QueryReturnsTextCellsWithDateOrTimeFormatAsString: one row with a numeric cell andt="s",t="str"andt="inlineStr"cells sharing a date format, plus a numeric cell and at="s"cell sharing a time format. The numeric cells still come back asDateTime/TimeSpanand the text cells asstring. It fails without the fix.Helpers.ReplaceSharedStringsXml: test helper mirroringReplaceStylesXml.MiniExcelTestspasses 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.