Skip to content

fix: read what real xlsx writers write; producer fixtures from seven writers - #42

Merged
vaceslav merged 5 commits into
mainfrom
test/producers
Sep 27, 2026
Merged

vaceslav merged 5 commits into
mainfrom
test/producers

Conversation

@vaceslav

Copy link
Copy Markdown
Contributor

Part of #16, item 5 (producer diversity).

tests/TriasDev.Tabular.Tests/Fixtures/Producers holds one small table as seven real producers write it: ClosedXML 0.105, the Open XML SDK 3.5, EPPlus 4.5.3.3, NPOI 2.7.6, MiniExcel 1.46, Sylvan.Data.Excel 0.5.8 and LibreOffice 26.8 (as xlsx, ods and csv). The files are embedded in the test assembly, and ProducerFixtureTests reads the table back from each. They are generated by a new write-producers mode of the comparison project; the README gives the commands. Google Sheets and Numbers are left out, since neither can be driven from a script. The files' metadata was checked and holds no user or path.

Reading them turned up three reader defects. Each fix has a named test that failed first (ProducerSpellingsTests):

  • fix(xlsx): _xHHHH_ escapes. ECMA-376 escapes a character as _xHHHH_, and an underscore that would start an escape as _x005F_. We read the escapes raw, so MiniExcel's emoji came back as _xD83D__xDE00_. A typed _x000D_ came back as _x005F_x000D_ from ClosedXML, EPPlus, Sylvan and LibreOffice. Escapes are now decoded in shared strings, inline strings and formula strings.
  • fix(xlsx): booleans written as true/false. new CellValue(true) in the Open XML SDK writes true. Every boolean such a file held read as false.
  • fix(xlsx,ods): literal line ends. XML reads a carriage return, alone or before a line feed, as a line feed. The sheet scanner kept it, so MiniExcel's \r\n survived in a value. The shared string table, which goes through XmlReader, was already normalised, so the same value read two ways depending on where it was stored. A character reference such as 
 still keeps its carriage return.

The fuzz now also covers _x sequences, which the xlsx writer escapes as writers do, and line feeds written as a literal \r\n. Both run clean at 20 000 cases.

NPOI and the Open XML SDK do not escape a typed _x000D_, so it reads as a carriage return, which trimming then removes. Excel reads it the same way. The test records this rather than hiding it.

Also: HostileInputTests.ReadsAQuoteStormWithoutTakingQuadraticWork now discards a first run, so once-per-process costs cannot flatter the ratio (#16, item 4).

Every read fingerprint of the local real-file corpus (11 csv files, 4 large workbooks) matches main. Timing is still to measure on a quiet machine before merge.

@vaceslav

Copy link
Copy Markdown
Contributor Author

Quiet-machine timing, median of 3 alternating runs against main: every file within −0.7 % to +0.8 % (5M-row malformed csv −0.5 %, 1M-row workbook +0.1 %, 11M-row csv +0.2 %); every read fingerprint identical.

@vaceslav
vaceslav merged commit 22899e8 into main Sep 27, 2026
9 checks passed
@vaceslav
vaceslav deleted the test/producers branch September 27, 2026 21:18
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.

1 participant