Exporting large datasets to Excel in Java often triggers repeated OutOfMemoryErrors even after bumping heap limits, while hand-rolling Apache POI streaming code across endpoints creates tedious maintenance work. StreamSheet is a Spring Boot library that replaces that boilerplate with a single annotation.

Exporting 1 Million Rows Without Heap Spikes

Instead of loading an entire query result into memory at once, StreamSheet reads rows sequentially from a JPA Stream or JDBC ResultSet and writes the Excel stream on the fly. Garbage collector pressure stays flat, and process memory usage remained steady under load tests.

Because it works across standard relational databases, dropping it into an existing Spring Boot service imposes almost no architectural constraints.

Declarative Setup with a Single Annotation

Adding an annotation to your DTO completes the mapping. Spring Boot Auto-configuration wires the internals as soon as you add the dependency: declare the return type on your controller method, and the built-in converter opens the stream and flushes rows directly to the response.

Reordering columns or renaming headers takes a one-line annotation change rather than re-indexing cell coordinates by hand, retiring a whole class of Apache POI maintenance work.

Summary

  • Sequential streaming over JPA Stream and JDBC ResultSet exports 1 million Excel rows without OutOfMemoryErrors
  • Declarative annotations eliminate manual Apache POI cell-index boilerplate
  • Spring Boot Auto-configuration lets existing services adopt streaming exports just by adding the dependency

Related Posts