I am getting empty excel and empty csv content inside while clicking the anchor Links in my application in vaadin 13.using version 3.0.0. code:
grid.addColumn(counterNameSummary → counterNameSummary.getPageRequests() != null ? counterNameSummary.getPageRequests().toString() : “”).setHeader(“Pagerequests”).setFlexGrow(0).setWidth(“120px”).setSortable(true).setKey(“Pagerequests”);
add(new Anchor(new StreamResource(“my-excel.xls”, Exporter.exportAsExcel(grid)), “Download As Excel”));
add(new Anchor(new StreamResource(“my-excel.csv”, Exporter.exportAsCSV(grid)), “Download As CSV”));
grid.getDataProvider().refreshAll();
I didn’t see grid.setItems() or grid.setDataProviders() in the code above. Did you set data to the grid?
A couple of other things:
For the Exporter addon to work, a column key should match a getter method in the POJO, so for the language column, you need to have a getLanguage() method in CounterNameSummary.
No need to call grid.getDataProvider().refreshAll(); unless you have changed some items in the data provider
Hello Wang,
Thank you for your reply. Now i am able produce the excel file and csv files.
How to handle when pagination is available in the grid.?Because now it download only visible items in the screen list.