Hey Jignesh, for reading numeric data from an excel sheet you need to use Apache POI. Apache POI provides getNumericCellValue() method which return the numeric value of excel sheet cells. Following example shows how to do that:
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.testng.annotations.Test;
public class ReadExcel
{
@Test
public void testReadCellNumeric() throws Throwable, IOException
{
String path=System.getProperty("user.dir");
// load workbook
XSSFWorkbook wb=new XSSFWorkbook(new FileInputStream(new File(path+"/TestData/AppTestData.xlsx")));
// read numeric data
int data= (int)wb.getSheetAt(0).getRow(0).getCell(1).getNumericCellValue();
// print on console
System.out.println("Data from Excel is >>> "+data);
}
}