Currently i am using String data= sheet1.getRow(row).getCell(column).getStringCellValue();
It works properly for String value but displays error for numeric value.
So i have to add numeric value like "34567" in excel.
Is there any other method to fetch both numeric and String ?
Asked
Active
Viewed 4,665 times
0

mahendra sonavane
- 11
- 1
- 3
2 Answers
1
You will get an error when you try to fetch the numeric cell as String.
You should be setting the cellType as string like below, before fetching the numeric cell.
HSSFCell yourCell = sheet1.getRow(row).getCell(column);
yourCell.setCellType(Cell.CELL_TYPE_STRING);
String data = yourCell.getStringCellValue();

Vijay
- 542
- 4
- 15
-
Thanks a lot vijay .. it works for me .. :) Appreciate your knowledge :) @vijay – mahendra sonavane Jun 06 '16 at 10:34
0
in the template excel change the column type as string.then get the value as string as follows sheet1.getRow(row).getCell(column).getStringCellValue().Then pasrse to integer or whatever.

Ajay
- 87
- 7