0

I am trying to fetch test data from the excel sheet but it reads the integer value as decimal. Every integer value comes up with a decimal followed by zero.

  1. I have used apache poi for data driven testing.
  2. Method to fetch String values as well as Integer values from the excel sheet is common.
  3. Have attached the screenshots of the excel sheet data, method for fetching test data from the excel sheet and of the Testcase.

Please suggest.

enter image description here

enter image description here

enter image description here

Ujjawal
  • 35
  • 1
  • 5
  • Don't use `toString` but format the value properly based on the cell type? – Gagravarr Jul 12 '22 at 21:56
  • For [example](https://stackoverflow.com/a/3562214/230513). – trashgod Jul 12 '22 at 22:26
  • 1
    `Cell.toString()` is not the correct way to get cell values as strings. It gets the stored raw values as strings instead the formatted values as Excel shows them. Use `DataFormatter` for this task. See https://stackoverflow.com/questions/7608511/java-poi-how-to-read-excel-cell-value-and-not-the-formula-computing-it/71390145#71390145. – Axel Richter Jul 13 '22 at 03:41
  • I got it working. I manually changed the format of the values as Number in the excel sheet. Didn't need to change the code. Thanks anyway. – Ujjawal Jul 13 '22 at 06:56

0 Answers0