← 输入框|github.com|刷新
Skip to content

Read b and bb as Buddhist era year date codes - #798

Merged
appel1 merged 2 commits into
ExcelDataReader:developfrom
zzoraemon043:fix/buddhist-year
Dec 1, 2026
Merged

appel1 merged 2 commits into
ExcelDataReader:developfrom
zzoraemon043:fix/buddhist-year

Conversation

@zzoraemon043

Copy link
Copy Markdown
Contributor

Excel reads b and bb (two-digit) and bbbb (four-digit) as the Buddhist era year. ExcelDataReader does not know the b code, so a cell with a format such as bbbb is read as a double, not a DateTime.

Excel 365, value 45306.25:

Format Excel shows Before After
bbbb 2567 double DateTime
bb 67 double DateTime
BBBB (Excel saves it as bbbb) 2567 double DateTime
"Year "bbbb Year 2567 double DateTime

A single b is saved by Excel as bb. An escaped or quoted b (0\b, 0"b") and [Blue] stay number formats.

Change: the tokenizer reads a run of b/B like the other date codes, and Token.IsDatePart counts it as a date part.

Tests: new cases in DateTokensMatchAsciiCaseOnly and FormatClassification_PreservesEndOfInputAndSections. Six of them fail before the change. The full ExcelDataReader.Tests suite passes on net10.0, net11.0 and net462, and the characterization snapshot is unchanged.

@appel1

appel1 commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

This is great, thank you.

Would you mind adding test Excel documents for the supported formats using these format strings?

xls, xlsx, xlsb and strict xlsx saved by Excel 365 with bbbb, bb, b, BBBB, bbbb/mm/dd, "Year "bbbb and [$-41E]bbbb/mm/dd as dates, and 0\b and 0"b" as numbers.
@zzoraemon043

Copy link
Copy Markdown
Contributor Author

Added in e3ae812: BuddhistEraYear as xls, xlsx, xlsb and strict xlsx, saved by Excel 365. Column A holds 45306.25 formatted as bbbb, bb, b (Excel saves it as bb), BBBB (saved as bbbb), bbbb/mm/dd, "Year "bbbb and [$-41E]bbbb/mm/dd, which should read as 2024-01-15 06:00, plus 0\b and 0"b", which stay numbers.

ExcelWorkbookTestBase.BuddhistEraYearFormatsAreDates runs it for all four formats; it fails on develop and passes with the fix.

@appel1
appel1 merged commit f66cb15 into ExcelDataReader:develop Dec 1, 2026
5 checks passed
zzoraemon043 added a commit to zzoraemon043/zzoraemon043 that referenced this pull request Dec 1, 2026
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