Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » NullPointerException when exporting nattable(NullPointerException when exporting nattable)
NullPointerException when exporting nattable [message #1052812] Tue, 30 April 2013 15:03 Go to next message
Chirpy Hummingbird is currently offline Chirpy HummingbirdFriend
Messages: 1
Registered: April 2013
Junior Member

I have recently upgraded Nattable to 0.9.0. I had to make very few changes to my application code for successfully migrating to the newer version. And the new version looks quite crisp.
One feature I like very much is the "Export to Excel" feature, which was broken in the older version.

I have added the 'Export' icon for this feature to one of the ViewParts in my application. Now I found one issue with the current implementation.
Here's how to reproduce it:
1. Click on the "Export" Icon
2. Internally I have associated with the org.eclipse.nebula.widgets.nattable.export.command.ExportCommand(IConfigRegistry configRegistry, Shell shell).
3. This command calls the ExportCommandHandler, which in turn calls the NatExporter.exportSingleLayer() API.
4. So on the UI I get a File Dialog to Save the xls.
5. If I choose to Save the file then everything works well.
6. However on the File Dialog if I select 'Cancel' and then again try to Export the ViewPart by clicking on the 'Export' icon I get following exception:

at org.eclipse.nebula.widgets.nattable.export.FileOutputStreamProvider.getOutputStream(
at org.eclipse.nebula.widgets.nattable.export.excel.ExcelExporter.getOutputStream(
at org.eclipse.nebula.widgets.nattable.export.NatExporter.exportSingleLayer(
at org.eclipse.nebula.widgets.nattable.export.command.ExportCommandHandler.doCommand(
at org.eclipse.nebula.widgets.nattable.export.command.ExportCommandHandler.doCommand(
at org.eclipse.nebula.widgets.nattable.command.AbstractLayerCommandHandler.doCommand(
at org.eclipse.nebula.widgets.nattable.layer.AbstractLayer.doCommand(
at org.eclipse.nebula.widgets.nattable.layer.CompositeLayer.doCommand(
at org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer.doCommand(
at org.eclipse.nebula.widgets.nattable.NatTable.doCommand(

The fix for this is pretty simple actually. To save the xls file there is a call to FileOutputStreamProvider.getOutputStream(Shell shell) method where the fileName is passed as an argument to the constructor.

fileName =;
if (fileName == null) {
return null;

Now if I choose to CANCEL the file dialog, fileName gets set to null, which is an instance variable. So next time when this method is called following code throws NullPointerException.

int lastIndexOfFileSeparator = fileName.lastIndexOf(File.separator);

The fix is, take the return value from to a local variable and compare that, instead of setting it to fileName

String dialogStatus =;
if(dialogStatus == null) {
return null;

Can we have this fix added in a patch please?

This export feature is one of the crucial functionality we are adding to our app.

You help is much appreciated.

Re: NullPointerException when exporting nattable [message #1052933 is a reply to message #1052812] Wed, 01 May 2013 13:16 Go to previous message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2751
Registered: July 2012
Senior Member
You should consider updating to 1.0.0 as we will release soon and there this bug should be fixed already. In the download section you should find the p2 update sites for the current snapshots
Previous Topic:NatTable evaluation
Next Topic:False display of columnWidths after restore via natTable.loadState()
Goto Forum:

Current Time: Thu Dec 05 18:12:57 GMT 2019

Powered by FUDForum. Page generated in 0.02014 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top