Repository navigation
feat!: .NET 10, streaming writer, fixes, opt-in WriteExcelAsync API - #32
Merged
Merged
Conversation
Targets net10.0 and net8.0. The original WriteExcel/ExportToExcel/GenerateExcel keep their signatures and output; they now run on a streaming writer that writes the xlsx parts straight into a zip instead of building an XML tree. 200k rows x 10 columns: 2.9 s -> 0.76 s, peak heap 945 MiB -> 13 MiB. Fixed (each verified against the published 8.0.6): - control characters in a string threw XmlException mid-export - NaN/Infinity, text over 32,767 chars, and types with no exportable properties produced files Excel refuses to open - the frozen header pane was written outside sheetView and ignored - every <col> targeted column 1, forcing column A to width 4 - empty strings were written as a newline plus indentation - an indexer property threw TargetParameterCountException - dictionary rows were matched by position, not key; an empty list threw - column letters were wrong from column 677 on New opt-in WriteExcelAsync: columns in the order given, computed columns (ExcelColumn<T>), dictionary/ExpandoObject rows, IAsyncEnumerable sources, typed booleans/dates/DateOnly/enums, auto-fit, bold header, autofilter, cancellation. DocumentFormat.OpenXml is no longer used but stays a dependency (now 3.5.1): four Traxis services compile only because this package brings it in.
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configuration
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Retargets the library to net10.0 + net8.0 and rewrites its internals as a streaming writer. Every existing method keeps its signature, column order and cell types. Merging publishes 10.0.0 to nuget.org.
Existing API: same output, but faster and fixed
WriteExcel/ExportToExcel/GenerateExcelnow run on a writer that streams the xlsx parts straight into a zip, instead of building the whole sheet as an in-memory XML tree.Equivalence check: I compared 9 cases covering every overload and all supported types, about 15k cells, against 8.0.6, checking type, style and value for each cell. Numbers, dates, decimals and floats are the same text.
Differences from 8.0.6. Each was reproduced against 8.0.6. Where it says Excel refuses a file, the file was opened in Excel and failed.
\x01,\v…) in a string: used to throwXmlExceptionmid-export. Now stripped.NaN/Infinity, text over 32,767 characters, or a type with no exportable properties: used to produce a file Excel refuses to open. Now written as text, truncated, and written as a valid empty sheet, respectively.<sheetView>, so Excel ignored it. It now works.<col>element pointed at column 1, which made column A 4 characters wide. Widths are no longer forced.TargetParameterCountException. Now skipped."A A"). Now correct.New opt-in API:
WriteExcelAsyncA separate method name, so existing callers are unaffected:
ExcelColumn<T>lambdas.IDictionary<string, object>,ExpandoObjectorIDictionary<string, string>.IAsyncEnumerable<T>sources are supported (e.g. EFAsAsyncEnumerable()), with cancellation.DateOnly, enums by name,Guid.Full details are in the README.
Compatibility notes
DocumentFormat.OpenXml: the library no longer uses it, but it stays a dependency, now 3.5.1 instead of 2.13.1. Accounting, Checkout, Rates and Warehouse have strayusing DocumentFormat.OpenXml…lines that compile only because this package brings it in. Dropping it broke all four builds.developagainst this package. All build with no source changes. Ship resolves OpenXml 3.5.1 alongside ClosedXML 0.105.0, with no range warnings.netstandard2.0).CI
major-versiongoes 8 → 10.run-tests: true, running 34 tests on both frameworks. Each test reads the output back and runs it throughOpenXmlValidator.