I have a table in the Excel file like this:
I would like to read the product ID and I have the code below:
public class ReadDataFromExcel extends Page {
public static void main(String[] args) {
ReadDataFromExcel rdfe = new ReadDataFromExcel();
String vOutput = rdfe.ReadCellData(1, 0);
//System.out.println(vOutput);
}
//method defined for reading a cell
public String ReadCellData(int vRow, int vColumn) {
String value = null; //variable for storing the cell value
Workbook wb = null; //initialize Workbook null
try {
//reading data from a file in the form of bytes
FileInputStream fis = new FileInputStream(System.getProperty("user.dir") + "//src//test//resources//executables//bCom pricing.xlsx");
//constructs an XSSFWorkbook object, by buffering the whole stream into the memory
wb = new XSSFWorkbook(fis);
} catch (IOException e) {
e.printStackTrace();
}
Sheet sheet = wb.getSheetAt(0); //getting the XSSFSheet object at given index
Row row = sheet.getRow(vRow); //returns the logical row
Cell cell = row.getCell(vColumn); //getting the cell representing the given column
//value = cell.getStringCellValue(); //getting cell value
switch (cell.getCellType())
{
case Cell.CELL_TYPE_STRING: //field that represents string cell type
value = cell.getStringCellValue() + "\t\t\t";
System.out.print(value);
break;
case Cell.CELL_TYPE_NUMERIC: //field that represents number cell type
value = cell.getNumericCellValue() + "\t\t\t";
System.out.print(value);
break;
default:
}
return value; //returns the cell value
}
}
Unfortuantely instead of 7199113022 I get the "7.100113022E9" in the console output. How this should be formatted to receive the exact number?