I have a field in the input xlsx file which can contain either email or mobile number. While reading it, I am having the following logic -
Workbook workbook = WorkbookFactory.create(new File("./TXN_Log_Mar_18_input.xlsx"));
Sheet sheet = workbook.getSheetAt(0);
Iterator<Row> rowIterator = sheet.rowIterator();
while (rowIterator.hasNext() && cnt <maxRows) {
System.out.println("\n\nNew row "+cnt+" ");
Row row = rowIterator.next();
if(row.getCell(11).toString() !="" || row.getCell(12).toString() !="")
{
String debitUser = row.getCell(11).toString();
System.out.println("input mobile? "+debitUser);
if(emailFormat(debitUser) || mobileFormat(debitUser))
{
response = umCall(debitUser);
}
}
}
With a proper 10 digit mobile number, following is the output -
input mobile? 7.358681129E9
DataFormatteras shown in Getting the cell contents.DataFormatter formatter = new DataFormatter();...String debitUser = formatter.formatCellValue(row.getCell(11));