Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Little problem while exporting JTable to excel  RSS feed

 
adeeb alexander
Ranch Hand
Posts: 268
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all.
I am trying to export the JTable to excel file. I am facing two problems. The first is when ever an empty column is present i get null pointer exception. The second is when ever the number is there it is converted to scientific format i.e (e+023) like that. I need to save the number as it is. Some one has any idea about it. Please help me out. The code is below






Thanks and Regards
alexander>
 
Rob Spoor
Sheriff
Posts: 20895
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First, the NullPointerException. That's caused by this line:
If the cell is empty, the value is quite often null. The following will fix that:
I'm not using String.valueOf because that will put the String literal "null" into s when the cell is empty.

As for the formatting issue, use a proper Excel API like Apache POI or JExcelAPI. You can specify the cell type; Excel has a nasty habit of applying its own formatting when numbers get too large.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!