The table component doesn’t expose all its contents at once on the client side due to performance reasons (only a reasonable cache buffer is loaded). You could call table.setCacheRate(0d) in order to force the table to load all the contents (not sure if it will solve your issue though). Otherwise - maybe it makes sense to forst export the table in Excel and the print it. This could be done with
this add-on.
I’m trying to export table data as HTML, putting the table content as HTML on a Label component, with css styles. But when printing, the resulting printed document seems to be without styles.
This is the code I used:
Window printWindow = new Window("Print");
printWindow.setSizeFull();
// converti la Table in HTML
String html = "styled content here";
Label content = new Label(html,Label.CONTENT_XHTML);
content.setSizeFull();
VerticalLayout layout = new VerticalLayout();
layout.setSizeFull();
layout.addComponent(content);
printWindow.setContent(layout);
getApplication().addWindow(printWindow);
getApplication().getMainWindow().open(new ExternalResource(printWindow.getURL()), "_blank");
// Print automatically when the window opens.
// This call will block until the print dialog exits!
printWindow.executeJavaScript("print();");
// Close the window automatically after printing
printWindow.executeJavaScript("self.close();");