• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

POI: Setting cell type error

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • 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
  • 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: 21804
104
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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.
 
today's feeble attempt to support the empire
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!