Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » Export to Excel with UTF-8 encoding
Export to Excel with UTF-8 encoding [message #1463768] Thu, 06 November 2014 22:40 Go to next message
Thomas Zwickl is currently offline Thomas ZwicklFriend
Messages: 37
Registered: May 2014
Member
Hi,

I'm using the following command to export the current table to a excel file:
final ExportCommand cmd = new ExportCommand(natTable.getConfigRegistry(), natTable.getShell());
natTable.doCommand(cmd);

This works all fine, but the problem is that when I'm going to open the excel file all my special characters won't be displayed correctly which is very annoying.
I just opened the file with a text editor and I've found the following line:
<html xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/html; charset=windows-1252">
<meta name=ProgId content=Excel.Sheet>

When I manually change the charset from windows-1252 to UTF-8 everything works fine but I cannot expect that the user has to manually change this in order to correctly open the excel file, so my question is can I somehow change the encoding used by Nattable?

Thanks in advance for your help.

Best regards,
Thomas
Re: Export to Excel with UTF-8 encoding [message #1464075 is a reply to message #1463768] Fri, 07 November 2014 06:40 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2803
Registered: July 2012
Senior Member
Currently not. The ExcelExporter is internally reading a template for the header of the file that contains the encoding hard coded.

For now you could either implement and register a custom ExcelExporter or use the Apache POI extension with the HSSFExcelExporter.

But please also create a ticket in Bugzilla so we modify the codebase to be able to specify the charset.
Re: Export to Excel with UTF-8 encoding [message #1464190 is a reply to message #1464075] Fri, 07 November 2014 09:23 Go to previous message
Thomas Zwickl is currently offline Thomas ZwicklFriend
Messages: 37
Registered: May 2014
Member
Thanks for the quick answer Wink
OK I've now created my own customised excel exporter where I use now my own excelExportHeader.txt with the desired charset encoding.

And yes I'll create a bug report about this.
Previous Topic:Disable to Done button on Column chooser Dialog pragmatically on conditions
Next Topic:NatCombo with Images
Goto Forum:
  


Current Time: Sat Mar 06 06:33:46 GMT 2021

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

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

Back to the top