• 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
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

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: 22815
132
Eclipse IDE Spring Chrome 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.
 
Destiny's powerful hand has made the bed of my future. And this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic