• 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

POI: Setting cell type error

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm reading an excel file that contains some numeric value using Apache POI and I want to convert then to a string
when I type cell.setCellType(Cell.CELL_TYPE_STRING);  It shows like this (http://imgur.com/a/hZvUl) and I get an NullPointerException  
can anyone help me?
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The strikethrough text is most likely how your IDE warns you that you are using deprecated methods - methods that are from an old version of an API, that you are not supposed to use anymore.

Can you show us more of your code than just that one line? Otherwise it's really hard to help you and to find out why you get a NullPointerException.

In general, one of the reasons you can get a NullPointerException is when you try to call a method on a variable that is null. If it happens in the line in your image, then most likely the variable cell is null.
 
Sheriff
Posts: 22815
132
Eclipse IDE Spring Chrome Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jesper de Jong wrote:The strikethrough text is most likely how your IDE warns you that you are using deprecated methods - methods that are from an old version of an API, that you are not supposed to use anymore.


Usually you're right, but I happen to know this one. In the current version of POI, they deprecated the int cell types and everything that's related to it. However, the enum replacement will not be added until POI 4. That's right - they deprecated it in advance without providing the alternative. They should have just waited with deprecating until the replacement was in place.

So Qubayel, in this case, you can ignore this deprecation warning.
 
Hug your destiny! And hug 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