Reports: Render XLS/XLSX and ODS Output in Vaadin Spreadsheet jmix-framework/jmix#5138#5308
Open
KremnevDmitry wants to merge 15 commits into
Open
Conversation
…amework/jmix_5138
…amework/jmix_5138
…amework/jmix_5138
…amework/jmix_5138
…amework/jmix_5138
…amework/jmix_5138
…amework/jmix_5138
…amework/jmix_5138
…amework/jmix_5138
…amework/jmix_5138
…amework/jmix_5138
…amework/jmix_5138
…amework/jmix_5138
…amework/jmix_5138
…amework/jmix_5138
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.
See: #5138
Reports Spreadsheet
The Reports Spreadsheet add-on enables in-browser rendering of XLS/XLSX report output via the Vaadin Spreadsheet component. Instead of downloading the generated report file, users can open it in a dialog with a fully-functional spreadsheet viewer, review the data, optionally edit cells, and download the modified workbook.
The add-on is a premium module available for Jmix applications.
Getting Started
Add the runtime dependency to your project:
implementation 'io.jmix.reports:jmix-reports-spreadsheet-flowui-starter'The add-on auto-activates only when all of the following are present on the classpath:
jmix-reports-flowui, the Vaadin Spreadsheet add-on (io.jmix.spreadsheet:jmix-spreadsheet-starter), and the Vaadin Spreadsheet component itself.Once enabled, the existing
Reportsviews (Reports list,Run report,Execution history) automatically expose new actions —Open in Spreadsheetnext to the standardRun/Downloadactions.Basic concepts
Report Execution Presentation
A Report Execution Presentation is a strategy that defines how a particular output channel selects templates, output types, and decides whether a parameters dialog is required. Each presentation has a stable identifier registered in
ReportExecutionPresentationIds:The OSS
reports-flowuimodule shipsDefaultReportExecutionPresentationandTableReportExecutionPresentation. The premium add-on contributesSpreadsheetReportExecutionPresentation, which restricts template and output choices to combinations renderable by the Vaadin Spreadsheet (currently XLS/XLSX).To register a custom presentation, implement
ReportExecutionPresentationand expose it as a Spring bean:Report Result Handler
A Report Result Handler receives the generated
ReportOutputDocumentafter the runner finishes execution and decides what to do with it. Handlers form an ordered chain — each is called until one returnstrue:Built-in handlers:
TableReportResultHandler— opens table-output reports inReportTableView.SpreadsheetInlineReportResultHandler(premium) — opens XLS/XLSX output inReportSpreadsheetViewwhen the run context targets theSPREADSHEETpresentation.If no handler claims the document,
UiReportRunnerImplfalls back to the standard download viaReportDownloader. This means the result-handling pipeline is open for extension: a project can add@Component-level handlers (with@Order) to intercept output for custom channels (e-mail, S3 upload, in-app viewer, etc.) without modifying the runner.Report Presentation Registry
ReportPresentationRegistryis the central service that resolves the active presentation for a run context, wraps a context to target a specific presentation, and applies the presentation's defaults (template, output type) before execution:The registry is internal API. Premium and user code that needs to open a report in the spreadsheet should use the public
SpreadsheetReportRunnerhelper:ReportSpreadsheetView
ReportSpreadsheetViewis the dialog view that hosts the Vaadin Spreadsheet component. It accepts either abyte[]content (generated report output) or a storedFileRef(an execution-history record), reads the workbook into the spreadsheet, and provides:Downloadbutton that exports the current workbook state (including user edits) viaReportDownloader,Closeaction,xls, XSSF →xlsx) for the downloaded file.The view is registered in the application context via
ReportsSpreadsheetFlowUiConfiguration, which scans theio.jmix.reportsspreadsheetflowui.viewpackage.Module structure
The auto-configuration is gated by
@ConditionalOnClass(checks forReportsFlowuiConfiguration,VaadinSpreadsheetConfiguration,com.vaadin.flow.component.spreadsheet.Spreadsheet) and@ConditionalOnBean(UiReportRunner), so dropping the dependency on the classpath is sufficient to enable the feature, and missing any prerequisite cleanly deactivates the module.Useful resources