Streaming xlsx reports#5480
Open
KremnevDmitry wants to merge 5 commits into
Open
Conversation
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.
Summary
Added streaming XLSX report generation for large datasets: a report band can be marked to render row-by-row straight from a database cursor, so memory stays bounded regardless of row count (verified at ~1M rows). The feature is opt-in per band and inert for existing reports.
What was done
streamingflag (BandDefinition, exposed viaReportBand/ReportQuery) and a Streaming checkbox in the report editor, gated to a first-level band backed by a single SQL or JPQL dataset.StreamingReportDataLoaderabstraction.StreamingReportValidatorthat enforces the structural rules streaming requires (single dataset, first-level band, supported dataset type) and surfaces clear errors otherwise.jmix.reports.streaming.*(fetch size and related knobs, validated to be positive) and translations (default + ru) for the new UI.RecordFormatException/OOM on huge outputs.How it works
When a first-level band is marked streaming, the engine reads its rows from a forward-only database cursor and writes them directly into an SXSSF sheet one row at a time, so peak memory does not grow with the result size. Non-streaming bands and templates render through the existing engine unchanged. Formulas are resolved at write time — in-row formulas shift per band instance, and trailing aggregates placed below the data grow to cover all rendered rows. The render runs in a read-only transaction, and the persistence context is cleared periodically to bound managed-entity growth while lazy attributes stay resolvable through the open session. Output can be post-converted to CSV via a streaming writer.
How to use
In the report editor, check Streaming on a first-level band whose dataset is a single SQL or JPQL query (the checkbox is disabled for other configurations). Run the report with an XLSX or CSV template as usual — the streaming engine is chosen automatically. Adjust
jmix.reports.streaming.fetch-sizeand related properties if the default cursor page size doesn't suit the data store.Compatibility
Opt-in and backward compatible: bands are non-streaming by default, and any report that doesn't set the flag renders exactly as before.