Repository navigation
Read aaa, aaaa and e in number formats as date codes - #1081
Open
vtxe02023274 wants to merge 1 commit into
Open
vtxe02023274 wants to merge 1 commit into
vtxe02023274 wants to merge 1 commit into
Conversation
Contributor
This branch has not been deployed
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.
aaaandaaaa(short and long day of the week) ande(year of the era, the ROC year in a Taiwan workbook, the era year in a Japanese one) are date codes in Excel, but the format tokenizer has no rule for them.aandeare reserved characters, so they are not read as literals either, and the whole format is a syntax error. Common formats such asm/d (aaa),yyyy/m/d aaaa,e/m/dand[$-411]ge.m.dare therefore not date formats, andQueryreturns the serial number (45306) instead of theDateTime.Excel 365 with the value 45306.25:
aaam/d (aaa)aaaa h:mme/m/d[$-411]ge.m.dReadTokennow reads a run ofeand a run of three or moreaas tokens, andIsDatePartcounts them as date parts.e+ande-are still read first, so0.00E+00stays a number format. A singleaoraais not a code (Excel saves it as\a), so it is left as before.As a side effect
IsValidis now true for these formats, soSheetStyleFormatsCachekeeps them on export instead of dropping them.Tests in
MiniExcelGithubIssuesTests:TestDateFormatWithWeekdayOrEraYear: the formats above are date formats;0.00E+00,##0.0e-0,0 \aand0 "aaa"are notTestQueryDateWithWeekdayOrEraYearFormat: a ClosedXML workbook with four of these formats reads back asDateTimeBoth fail on master and pass with this change.
tests/MiniExcel.OpenXml.Tests(574 tests) andtests/MiniExcel.Csv.Testspass on net8.0, net10.0 and net11.0, andsrc/MiniExcel.OpenXmlbuilds for all targets including netstandard2.0. I did not have a net9.0 runtime here.Summary by CodeRabbit