Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » Save to excel
Save to excel [message #1057805] Wed, 08 May 2013 21:56 Go to next message
Testr t is currently offline Testr tFriend
Messages: 93
Registered: April 2013
Member
Hi,

I am able to use the excel export functionality for the tree grid that I am using but I find one minor issue. I see the data correctly exported except for the first Name column where instead of showing the name displayed in view it shows the object name. something like com.test.nat.DataRow@2d1fcace. I am using the tree grid with the IColumnPropertyAccessor providing data for all columns.

This is how I added the excel export option
//Add export to excel option
configRegistry.registerConfigAttribute(ILayerExporter.CONFIG_ATTRIBUTE, new HSSFExcelExporter());

And in the grid export option i tied to a toolbar action

public void ExportToExcel()
{
natTable.doCommand( new ExportCommand( natTable.getConfigRegistry(), natTable.getShell() ) );
}

Here is the getDataValue method implementation in IColumnPropertyAccessor

@Override
public Object getDataValue( DataRow row, int col )
{
//System.out.println("col accessor for Row: " + row.getAddress() + "Col: " + col );
String value;
if( col == 0 )
value = row.getName();
else if( col == 1 )
value = row.getAge();
else
value = row.getData( col );
return value;
}
In the plugin view I see the data correctly. The first column shows the DataRow Name value. The problem is only in the exported excel. Is there anything extra that I have to configure for excel export?
Re: Save to excel [message #1057837 is a reply to message #1057805] Thu, 09 May 2013 08:13 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
I think you need to register an IExportFormatter
Re: Save to excel [message #1057895 is a reply to message #1057837] Thu, 09 May 2013 15:24 Go to previous message
Testr t is currently offline Testr tFriend
Messages: 93
Registered: April 2013
Member
Thanks Dirk. Is there an example that I could look at for the IExportFormatter implementation. I looked into the DefaultExportFormatter implementation but I do not understand what I have to do to get the Name column display name in the exported excel. Currently except for the Name Column, all columns display hex values(I have added HexLabels for all those columns and a HexValidator implementation).
Previous Topic:Filter from database
Next Topic:Update / refresh Nattable
Goto Forum:
  


Current Time: Sat Apr 20 01:50:29 GMT 2024

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

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

Back to the top