Rows stream one at a time from a database through a small compression buffer into an Excel file ready for download; below, a memory chart where the streaming line stays flat while a dashed in-memory line keeps climbing
Back to blog
HypaxelExcelXLSX

Hypaxel: How a Slow Excel Export Became an Open-Source Library

Sascha KieferDevelopment

TL;DR

  • Hypaxel writes XLSX files as a stream, so memory stays flat whether you export 10 rows or a million.
  • In .NET 10 it writes 100,000 rows in about 73 ms with 13 KB allocated, where ClosedXML needs about 1.7 s and 1.1 GB.
  • The library is free under Apache 2.0 for .NET, Rust, Python, Node.js, browsers, Go, Java and PHP; Pro licenses add security and compliance modules.

In a customer project, generating Excel files on the server was slow and ate memory. Looking into it together with AI led to a different approach: write the workbook as a stream, one cell at a time. The result is Hypaxel, a family of constant-memory XLSX writers and readers for .NET, Rust, Python, Node.js, Go, Java and PHP, now open source under Apache 2.0.

In a customer project we generated Excel files on the server: reports that users downloaded straight from the web application. It worked, but it was slow, and every large export pushed the memory of the service up noticeably. With several users exporting at the same time, that became a real problem.

Where the memory went

The usual libraries build the whole workbook as an object model in memory first and only write it out at the end. Every cell becomes an object, every row a list. For a few hundred rows nobody notices. For a few hundred thousand, the export suddenly needs gigabytes, the garbage collector works overtime and the user waits for the first byte until the very last row is done.

I went through the problem together with AI: profiling, reading the XLSX format, sketching alternatives. What stood out was obvious in hindsight: an .xlsx file is a ZIP archive of XML files, and nothing forces you to hold it in memory. You can write each cell as UTF-8 XML the moment it arrives, compress it straight into a small buffer and pass that buffer on to the file or the HTTP response. That idea became Hypaxel.

What it looks like in C#

In ASP.NET Core, an export from Entity Framework is a single call. Rows stream from the database to the browser without ever being collected in a list:

using Hypaxel.AspNetCore;

app.MapGet("/orders.xlsx", (AppDb db) =>
    Results.Extensions.Excel(db.Orders.AsNoTracking().AsAsyncEnumerable(), "orders"));

If you want to control styles and layout yourself, write cell by cell:

using Hypaxel;
using Hypaxel.Styling;

await using var writer = XlsxWriter.Create("orders.xlsx");
var money = writer.AddStyle(new CellStyle { NumberFormat = NumberFormats.Thousands2 });
var sheet = writer.AddWorksheet("Orders", new WorksheetOptions { FrozenRows = 1 });

await sheet.AddRowAsync("Id", "Customer", "Total", "Created");
foreach (var order in orders)
{
    sheet.Write(order.Id);
    sheet.Write(order.Customer);
    sheet.Write(order.Total, money);
    sheet.Write(order.CreatedAt);
    await sheet.EndRowAsync();
}

await writer.CompleteAsync();

The numbers for .NET

Writing 100,000 rows with 10 columns on .NET 10 (Apple M1 Max, BenchmarkDotNet):

LibraryTimeAllocated
Hypaxel, typed Write73 ms13 KB
Hypaxel, object mapping78 ms15 KB
SpreadCheetah74 ms16 KB
ClosedXML1,749 ms1,103 MB

Depending on the .NET version, Hypaxel is roughly 19 to 24 times faster than ClosedXML's in-memory model at 100,000 rows and allocates kilobytes instead of gigabytes. At one million rows it needs about 0.7 seconds on .NET 10 and allocates less than 1 MB. SpreadCheetah, also a streaming writer, is on par with it; ClosedXML isn't measured at that size. Results for .NET 8 to .NET 11 and the methodology are on the benchmarks page.

Not just .NET

The same design exists for Rust, Python, Node.js, the browser (WebAssembly), Go, Java and PHP. .NET, Rust, Go, Java and PHP are independent native implementations; Python and Node.js build on the Rust core. Apart from PHP, every implementation can also read XLSX files as a stream.

Why open source

Slow Excel exports are not a problem only our customer had. Almost every business application has one somewhere, and more and more of that code is written by AI agents that reach for the familiar in-memory libraries. That's why Hypaxel is licensed under Apache 2.0. You can use it commercially, and an agent can pull it in like any other permissive library.

If you need more, there is a Pro license. It covers the whole legal entity, not each developer, agent or server. It includes the security and compliance modules we are building next, such as encrypted workbooks, sensitivity labels and digital signatures. Subscribers get them as they are released. The open-source core stays free.

Installation guide and API docs are on hypaxel.libs.vensas.de.

Sources

Need support?

Slow exports, high memory use and timeouts under load rarely come down to one big mistake. Usually it is a few small decisions in the request pipeline. As a .NET development partner we track those down and fix them, in an Excel export as much as across a whole service. If your application spends more time generating files than it should, get in touch.

.NET development at vensas