Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Tableexport Add-on, Gives null pointer exception !!!
Hi All,
On using this new add-on 'Tableexport' i get null pointer exception. While initializing Export table object.
I am quite new to vaadin, any help would be useful
Below is my code and the exception log
package com.example.tableexport;
import org.apache.poi.hssf.util.HSSFColor;
import org.apache.poi.ss.usermodel.CellStyle;
import com.vaadin.addon.tableexport.ExcelExport;
import com.vaadin.terminal.ThemeResource;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.Table;
import com.vaadin.ui.VerticalLayout;
@SuppressWarnings("serial")
public class TableExportExample extends VerticalLayout {
public TableExportExample(){
final Table table = new Table("This is my Table");
/* Define the names and data types of columns.
* The "default value" parameter is meaningless here. */
table.addContainerProperty("First Name", String.class, null);
table.addContainerProperty("Last Name", String.class, null);
table.addContainerProperty("Year", Integer.class, null);
/* Add a few items in the table. */
table.addItem(new Object[] {
"Nicolaus","Copernicus",new Integer(1473)}, new Integer(1));
table.addItem(new Object[] {
"Tycho", "Brahe", new Integer(1546)}, new Integer(2));
table.addItem(new Object[] {
"Giordano","Bruno", new Integer(1548)}, new Integer(3));
table.addItem(new Object[] {
"Galileo", "Galilei", new Integer(1564)}, new Integer(4));
table.addItem(new Object[] {
"Johannes","Kepler", new Integer(1571)}, new Integer(5));
table.addItem(new Object[] {
"Isaac", "Newton", new Integer(1643)}, new Integer(6));
final ThemeResource export = new ThemeResource("../images/table-excel.png");
final Button excelExportButton = new Button("Export to Excel");
excelExportButton.setIcon(export);
addComponent(table);
addComponent(excelExportButton);
excelExportButton.addListener(new ClickListener() {
private static final long serialVersionUID = -73954695086117200L;
private ExcelExport excelExport;
public void buttonClick(final ClickEvent event) {
excelExport = new ExcelExport(table);
excelExport.excludeCollapsedColumns();
excelExport.setDisplayTotals(false);
excelExport.setRowHeaders(true);
CellStyle cs = excelExport.getTitleStyle();
cs.setFillBackgroundColor(HSSFColor.GREY_25_PERCENT.index);
excelExport.setTitleStyle(cs);
excelExport.setDoubleDataFormat("0.00");
excelExport.setExcelFormatOfProperty("konto", "0");
excelExport.export();
}
});
}
}
Exception log
Feb 24, 2012 5:40:03 PM com.vaadin.Application terminalError
SEVERE: Terminal error:
com.vaadin.event.ListenerMethod$MethodException
Cause: java.lang.NullPointerException
at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:532)
at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:164)
at com.vaadin.ui.AbstractComponent.fireEvent(AbstractComponent.java:1219)
at com.vaadin.ui.Button.fireClick(Button.java:550)
at com.vaadin.ui.Button.changeVariables(Button.java:217)
at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.changeVariables(AbstractCommunicationManager.java:1451)
at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.handleVariableBurst(AbstractCommunicationManager.java:1399)
at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.handleVariables(AbstractCommunicationManager.java:1318)
at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.doHandleUidlRequest(AbstractCommunicationManager.java:763)
at com.vaadin.terminal.gwt.server.CommunicationManager.handleUidlRequest(CommunicationManager.java:296)
at com.vaadin.terminal.gwt.server.AbstractApplicationServlet.service(AbstractApplicationServlet.java:501)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:563)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:399)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:317)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:204)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:311)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException
at org.apache.poi.hssf.model.InternalWorkbook.doesContainsSheetName(InternalWorkbook.java:594)
at org.apache.poi.hssf.usermodel.HSSFWorkbook.createSheet(HSSFWorkbook.java:740)
at org.apache.poi.hssf.usermodel.HSSFWorkbook.createSheet(HSSFWorkbook.java:88)
at com.vaadin.addon.tableexport.ExcelExport.<init>(ExcelExport.java:200)
at com.vaadin.addon.tableexport.ExcelExport.<init>(ExcelExport.java:177)
at com.vaadin.addon.tableexport.ExcelExport.<init>(ExcelExport.java:156)
at com.vaadin.addon.tableexport.ExcelExport.<init>(ExcelExport.java:139)
at com.vaadin.addon.tableexport.ExcelExport.<init>(ExcelExport.java:125)
at com.vaadin.addon.tableexport.ExcelExport.<init>(ExcelExport.java:113)
at com.example.tableexport.TableExportExample$1.buttonClick(TableExportExample.java:52)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:512)
... 27 more
The null pointer exception seems to point to this part of the code 'excelExport = new ExcelExport(table);' .
Any kind of help to solve this problem would be greatly appreciated.
Thanks in advance.
Avinash Nair
Hello.
Did you resolve this problem?
I got the same error.
Thanks for your help.
Hi Guys,
You can resolve this problem by passing String value for sheet name as sheet name is going null,
excelExport = new ExcelExport(table,"mytable");
i am able to do it successfully ,please try ,it will work.