Skip to content

Makes it possible to export Vaadin Grids to different formats

License

Notifications You must be signed in to change notification settings

xdev-software/vaadin-grid-exporter

Repository files navigation

Published on Vaadin Directory Latest version Build Quality Gate Status Vaadin 24+

vaadin-grid-exporter

The Vaadin Grid Exporter can convert nearly any Vaadin Grid to a variety of formats.
This way you don't have to copy the Grid contents manually or print the whole website with the Grid.

Out of the box supported formats:

  • CSV
  • Word (DOCX)
  • HTML
  • ODS
  • ODT
  • PDF
  • PowerPoint (PPTX)
  • RTF
  • Plain text
  • Excel (XLSX)

These formats are exported using dynamicreports.

It's also easy to extend the Exporter to support your custom format.

demo

Note

Disclaimer about the scope of this component (click to expand)

Although the GridExporter can handle most use-cases, extreme scenarios will likely impact performance, usability and might require some hacks.
For such cases custom written exports are recommended e.g. by utilizing JasperReports directly.
If you need help implementing these feel free to contact us or open a question if you are not sure that the GridExporter is a good option for your scenario.

Usage

Default usage:

GridExporter
	.newWithDefaults(this.grExamples)
	.open();

Custom format (see JsonGridExporterProvider from Demo):

GridExporter
	.newWithDefaults(this.grExamples)
	.loadFromProvider(new JsonGridExporterProvider())
	.open();

Installation

Installation guide for the latest release

Comaptibility with CSP (Content-Security-Policy) and X-Frame-Options

Tip

In Spring Security the default value of X-Frame-Options is DENY which will break the preview if not changed.

To show the preview the CSP or the X-Frame-Options (deprecated in favor of CSP) must be configured in a way that they allow showing same-site elements.

This can be achieved by:

  • setting the CSP to include at least frame-ancestors 'self' and maybe additionally object-src 'self'
  • setting X-Frame-Options to SAMESITE.
    If you use Spring Security without a CSP the easiest way to set this is:
    http.headers(c -> c.frameOptions(HeadersConfigurer.FrameOptionsConfig::sameOrigin));

Note

Depending on the browser the settings sometimes have slightly different effects.
For example Firefox blocks the preview due to privacy reasons when X-Frame-Option=DENY and Content-Security-Policy=frame-ancestors 'self'; object-src 'self'; ... but Chrome does not.

Compatibility with Vaadin

Vaadin version GridExporter version
Vaadin 24+ (latest) 3+
Vaadin 23 2.x

Compatibility with JasperReports

Starting with version 3.1.0 JasperReports 7 is required.

Run the Demo

  • Checkout the repo
  • Run mvn install && mvn -f vaadin-grid-exporter-demo spring-boot:run
  • Open http://localhost:8080
Show example

demo

Support

If you need support as soon as possible and you can't wait for any pull request, feel free to use our support.

Contributing

See the contributing guide for detailed instructions on how to get started with our project.

Dependencies and Licenses

View the license of the current project or the summary including all dependencies