Skip to main content



      Home
Home » Eclipse Projects » NatTable » Save to excel
Save to excel [message #1057805] Wed, 08 May 2013 17:56 Go to next message
Eclipse UserFriend
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 04:13 Go to previous messageGo to next message
Eclipse UserFriend
I think you need to register an IExportFormatter
Re: Save to excel [message #1057895 is a reply to message #1057837] Thu, 09 May 2013 11:24 Go to previous message
Eclipse UserFriend
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: Sun Jul 20 07:59:57 EDT 2025

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

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

Back to the top