BAEL-3658: Fixed switch case indentations and added if condition to check if the cellType is FORMULA or not

This commit is contained in:
Sunil Jain 2020-01-04 11:16:33 +05:30
parent d2186b0dc7
commit 01a4b4b8a6

View File

@ -29,17 +29,17 @@ public class CellValueAndNotFormulaHelper {
if (cell.getCellType() == CellType.FORMULA) { if (cell.getCellType() == CellType.FORMULA) {
switch (cell.getCachedFormulaResultType()) { switch (cell.getCachedFormulaResultType()) {
case BOOLEAN: case BOOLEAN:
cellValue = cell.getBooleanCellValue(); cellValue = cell.getBooleanCellValue();
break; break;
case NUMERIC: case NUMERIC:
cellValue = cell.getNumericCellValue(); cellValue = cell.getNumericCellValue();
break; break;
case STRING: case STRING:
cellValue = cell.getStringCellValue(); cellValue = cell.getStringCellValue();
break; break;
default: default:
cellValue = null; cellValue = null;
} }
} }
@ -48,7 +48,7 @@ public class CellValueAndNotFormulaHelper {
} }
public Object getCellValueByEvaluatingFormula(String fileLocation, String cellLocation) throws IOException { public Object getCellValueByEvaluatingFormula(String fileLocation, String cellLocation) throws IOException {
Object cellValue; Object cellValue = new Object();
FileInputStream inputStream = new FileInputStream(new File(fileLocation)); FileInputStream inputStream = new FileInputStream(new File(fileLocation));
Workbook workbook = new XSSFWorkbook(inputStream); Workbook workbook = new XSSFWorkbook(inputStream);
@ -61,18 +61,20 @@ public class CellValueAndNotFormulaHelper {
Row row = sheet.getRow(cellAddress.getRow()); Row row = sheet.getRow(cellAddress.getRow());
Cell cell = row.getCell(cellAddress.getColumn()); Cell cell = row.getCell(cellAddress.getColumn());
switch (evaluator.evaluateFormulaCell(cell)) { if (cell.getCellType() == CellType.FORMULA) {
case BOOLEAN: switch (evaluator.evaluateFormulaCell(cell)) {
cellValue = cell.getBooleanCellValue(); case BOOLEAN:
break; cellValue = cell.getBooleanCellValue();
case NUMERIC: break;
cellValue = cell.getNumericCellValue(); case NUMERIC:
break; cellValue = cell.getNumericCellValue();
case STRING: break;
cellValue = cell.getStringCellValue(); case STRING:
break; cellValue = cell.getStringCellValue();
default: break;
cellValue = null; default:
cellValue = null;
}
} }
workbook.close(); workbook.close();