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

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: 22784
131
Eclipse IDE Spring VI Editor 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.
 
Would you turn that thing down? I'm controlling a mind here! Look ... look at the tiny ad ...
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic