• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Little problem while exporting JTable to excel

 
Ranch Hand
Posts: 268
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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>
 
Sheriff
Posts: 22862
132
Eclipse IDE Spring TypeScript Quarkus Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
This tiny ad is wafer thin:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic