Join 500+ Software Testing professionals. Solve problem and get your problem solved. Register Now!

Reading Numeric data form excel in data driven Framework ?

Solved 1 Answers 38 Views
0 1
Hi friends,

             an excel sheet consist of 3 column

         NAME      ID      RS    

         Abhishek  10    5000

         karthik     10    350.56

My questions is, By using Poi jar file i get value's form each cell by using switch case like



return c.getStringCellValue();


return String.valueOf(c.getNumericCellValue());


            return "Cell not found";


if only one column means i will type cast it but -> just consider "n" number columns having decimal value and "n" number columns having Integer value's .

like this am getting my value from excel like

my output :

Abhishek 10.0 5000.0 --> karthik  10.0 350.56

am getting Integer value as decimal value ?

there 's any solution for this i need to get  integer values as integer value and decimal values as decimal values

1 Answer

Best answer
Have you tried using DataFormatter class?

DataFormatter will try its best to return the value as it looks like on the Excel file.

You can try the sample as below.

Workbook _workbook = WorkbookFactory.create(new File("my_file.xlsx"));
DataFormatter formatter = new DataFormatter();
Sheet s = _workbook.getSheetAt(0);
for (Row r : s) {
  for (Cell c : r) {

Try that and let us know.
answered by (872 points)
selected by
commented by (188 points)
Thank you and
i will try it ..
commented by (188 points)
Thank you
am getting exact values from excel

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.