Directory

← Back

Grid Exporter Add-on

Extension for exporting Vaadin's grid data to common formats

Author

Contributors

Rating

This is an addon that allows to export Vaadin's grid data to some formats like Excel, Docx, PDF and CSV.

Features:

  • Can configure which columns to export
  • Other templates can be used besides the basic templates
  • Optionally can create the export buttons automatically (default)

Sample code

    GridExporter<Person> exporter = GridExporter.createFor(grid);
    exporter.setExportValue(c, item->""+item.getBudget());
    exporter.setTitle("People information");
    exporter.setFileName("GridExport" + new SimpleDateFormat("yyyyddMM").format(Calendar.getInstance().getTime()));
    add(grid);
    GridExporter<Person> exporter = GridExporter.createFor(grid, "/custom-template.xlsx", "/custom-template.docx");
    HashMap<String,String> placeholders = new HashMap<>();
    placeholders.put("${date}", new SimpleDateFormat().format(Calendar.getInstance().getTime()));
    exporter.setExportColumn(nameColumn, false);
    exporter.setExportColumn(lastNameColumn, true);
    exporter.setAdditionalPlaceHolders(placeholders);
    exporter.setSheetNumber(1);
    exporter.setCsvExportEnabled(false);
    exporter.setTitle("People information");
    exporter.setFileName("GridExport" + new SimpleDateFormat("yyyyddMM").format(Calendar.getInstance().getTime()));
    add(grid);

Compatibility

(Loading compatibility data...)

Was this helpful? Need more help?
Leave a comment or a question below. You can also join the chat on Discord or ask questions on StackOverflow.

Version

New features:

  • Support hierarchical dataprovider
  • Apply conditional formatting in excel export
Released
2023-09-04
Maturity
TESTED
License
Apache License 2.0

Compatibility

Framework
Vaadin 23
Vaadin 24 in 2.1.0
Browser
Firefox
Safari
Google Chrome
iOS Browser
Android Browser
Microsoft Edge
Online