0

I am trying to read numeric values from excel sheet for now i have read excel sheet read it using apache poi api.

My problem is that I have long number in excel sheet like 123435578774 while it display like 1.23436E+11 I set value in excel sheet as original but when I read it in java code it displays like 1.23436E+11

Here is my code sample:

HSSFRow row = (HSSFRow) rows.next();
HSSFCell cell = row.getCell((short) 0);

if (cell != null){
    Object result = cell.getNumericCellValue();
    readNumber = result.toString();
    System.out.println(readNumber);
}
Sarz
  • 1,970
  • 4
  • 23
  • 43
  • The type of getNumericCellValue is double, and what you see is the default format for displaying a double with that many places. Use formatting, convert to long (if applicable), see org.apache.poi.ss.usermodel.DataFormatter. – laune Jul 03 '14 at 08:07
  • possible duplicate of [Get Cell Value from Excel Sheet with Apache Poi](http://stackoverflow.com/questions/5578535/get-cell-value-from-excel-sheet-with-apache-poi) – laune Jul 03 '14 at 08:09
  • @laune possible not duplicate because i have already read values from excel. I am facing format issue – Sarz Jul 03 '14 at 09:27
  • @laune as getNumericCellValue() returns double value when i try to write it manually IDE says : integer number too long : for double value = 123435510774 – Sarz Jul 03 '14 at 09:55
  • Well, then use `long`: 123435510774L – laune Jul 03 '14 at 10:34
  • the problem is in conversion from double to string, still its unresolved – Sarz Jul 07 '14 at 09:45

0 Answers0