Skip to Content
TExcelPerformance and large files

Performance and large files

On this page

TExcel parses worksheet XML row by row and writes ZIP entries in batches, avoiding a cell object tree for the entire worksheet. Use typed rows for fixed schemas and dictionaries for dynamic columns. Consume sequences directly and retain only the business results you need to reduce additional materialization.

Reading and writing 100,000 rows

These figures come from the published .NET 8 BenchmarkDotNet report in the TExcel README, using its Job with 3 warmups and 10 measured iterations. MiniExcel is the comparison. Complete operations include file I/O. Results from the separate ShortRun Job and other machines are not combined here.

100,000-row workloadTExcel meanCompared with MiniExcel
Write typed rows to XLSX182.87 ms22.9% less time, 82.3% less allocation
Read typed rows into a list238.77 ms52.5% less time, 84.3% less allocation
Enumerate typed rows, count only223.26 ms40.6% less time, 84.6% less allocation

For 100,000-row typed writes, managed allocation is 41,031.66 KB, compared with 232,293.94 KB. Streaming reads still allocate strings and entities; they avoid retaining a full result list without eliminating allocations.

Comparison by scale

Time is converted from microseconds to milliseconds. Allocation retains the report’s KB unit from Allocated. Each pair is TExcel / MiniExcel. Allocation measures cumulative managed allocation for one complete operation, not peak memory.

WorkloadRowsMean time, msManaged allocation, KB
Write typed rows1000.971 / 3.8021,794.87 / 15,687.84
Write typed rows10,00020.091 / 33.3606,946.49 / 36,439.35
Write typed rows100,000182.866 / 237.29941,031.66 / 232,293.94
Read typed rows into a list1000.194 / 1.894151.00 / 720.82
Read typed rows into a list10,00022.787 / 52.3088,571.34 / 55,438.66
Read typed rows into a list100,000238.770 / 503.10987,858.84 / 558,096.67
Read dictionaries into a list10,00026.208 / 63.05310,054.47 / 56,573.87
Write dictionaries10,00017.376 / 33.3355,773.77 / 35,241.51
Enumerate typed rows, count only100,000223.261 / 375.84285,822.90 / 556,055.82

Environment and measurement scope

ItemRecorded setting
CPUIntel Core Ultra 9 285H, 16 logical cores
OSWindows 11, 10.0.26200.8246
SDK / runtime.NET SDK 10.0.201 / actual runtime .NET 8.0.25, X64 RyuJIT
Tool and JobBenchmarkDotNet 0.15.8; Job-YFEFPZ, 3 warmups and 10 measured iterations
Typed readingFull enumeration followed by ToList, including parsing, entity conversion and the result list
Streaming readingFull enumeration and counting; still creates each entity but does not retain a complete list
WritingInput prepared beforehand; operation includes producing and completing an XLSX file

For 100,000-row typed writes, TExcel / MiniExcel standard deviations are 3.464 / 9.323 ms. Typed list reads are 16.922 / 3.751 ms, and streaming counts are 14.171 / 13.486 ms. See the original report  for other errors, ranges and GC values. This historical report does not identify exact tested library commits or package versions. Its figures describe the recorded workloads; measure the version you intend to deploy on your target environment.

The current benchmark source  uses six-column entities covering integers, text, floating-point values, dates and booleans, with typed, dictionary and counting methods. The current project targets .NET 10 and references MiniExcel 2.0.0. A rerun produces a new result set; those current settings do not establish the versions used in the historical .NET 8 report.

Implementation choices that reduce work

MechanismBehaviorHow to use it
Row parsingXmlReader reads worksheet XML sequentially; an internal row buffer grows with column width and is reusedEnumerate directly instead of calling ToList before processing
Header bindingTyped reads bind headers to properties once, then convert subsequent rowsPrefer Query<T> / ReadSheet<T> for fixed schemas to avoid a dictionary per row
Optional cell factsOrdinary reads do not collect each cell’s raw value, type and formula flagEnable includeCellFacts only when the import contract needs them
Batched XML outputWrite operations resolve column metadata once and flush worksheet batches; the current implementation flushes every 1,000 rowsSupply an enumerable or async sequence directly without copying it to another collection
Shared stringsRepeated text reuses a shared-string indexRepeated names and categories benefit; unique text still increases string-table memory
Fast compressionWorksheet ZIP entries use CompressionLevel.FastestMeasure compression, file size and I/O together with conversion time

Returned entities, dictionaries and arrays own their data; advancing the internal buffer does not overwrite them. Buffer reuse still involves allocations for decoded strings, conversions and result objects.

Bound memory for large files

Memory includes workbook state, the current row or write batch, retained application results, and output buffers. Switching to async APIs does not remove this state.

ScenarioRecommendationRemaining costs
Fixed-schema importEnumerate Query<T> / QueryAsync<T> directly and process bounded business batchesEntities, strings and conversion; avoid an unbounded set of processing tasks
Dynamic previewUse dictionaries when headers are needed and arrays for known positionsPer-row dictionaries allocate a hash table; arrays still copy each row’s values
Strict importReadSheetRows(includeCellFacts: true)Extra cell facts; bound the number of retained error details
Database exportSupply the database async sequence to WriteSheetAsync and propagate cancellationThe reader and connection stay occupied; both database and output speed affect total time
Paged exportCreate one writer, use WriteSheet for the first batch and AppendSheet for subsequent batches of that sheetOne source batch at a time; shared strings remain for the workbook lifetime
Large outputPrefer a file stream or another caller-owned stream with a suitable contractMemoryStream retains the whole compressed file; ToArray copies it again

Reading loads the workbook’s shared-string table. Writing retains unique strings and their indexes. Row processing reduces retention of worksheet objects and result lists, but memory still depends on unique text and workbook state. Multiple worksheets share that state.

Time both Complete / CompleteAsync metadata writing and writer disposal to finalize the ZIP. Deliver the file only after success. Include any worksheet-design post-processing in export timing.

Compare the two source strategies in database export: direct streaming avoids a batch list; key-based batches add round trips but finish each reader before output. Use CSV when text exchange is sufficient.

Measure a representative workbook

The standalone TExcel repository contains benchmark/TExcel.Benchmark; its entry point supports BDN --list flat and --filter. Existing TUtility_ method names are historical; their display names say TExcel. The project configures both a 10-iteration Job and ShortRun. Compare results within the same Job.

Fix row and column counts, data types, unique-text ratio, worksheet count, runtime, package versions, disk and output strategy. Match the file contents and list-retention scope, fully enumerate, then validate row counts and fields. To evaluate peak memory, separately record working-set or GC-heap peaks; Allocated cannot establish them.