I'm processing a .ods spreadsheet with the jOpenDocument library. Since I was processing strings, everything was ok, but when it comes to process numbers it's a pain.
In my code I iterate the spreadsheet and make some computations based on the value assumed by the cell at index x,y. Surprisingly enough, I can't get the class of the values I get:
BigDecimal ferialestringa;
while (true) {
boolean duplicate = false;
value = (String) sheet.getValueAt(0, count);
System.out.println(sheet.getValueAt(5, count).getClass());
ferialestringa = (BigDecimal) sheet.getValueAt(5, count);
This snippet prints out:
class java.math.BigDecimal
class java.lang.String
Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to java.math.BigDecimal
at InspectTwitter.main(InspectTwitter.java:78)
You can see that the value appears to belong to two different classes.
If I try to parse the returned object to a string, I get also another ClassCastException:
class java.math.BigDecimal
Exception in thread "main" java.lang.ClassCastException: java.math.BigDecimal cannot be cast to java.lang.String
at InspectTwitter.main(InspectTwitter.java:78)
Note that this time the class seems to be just BigDecimal.
I tried to find documentation but only Sheet.getValueAt(String) is available on this javadoc. (I've found this method in tutorials though, and it seems to be working very well on strings). What should I do?