in pricat/src/main/java/org/apache/ofbiz/pricat/AbstractPricatParser.java [581:686]
public List<Object> getCellContents(XSSFRow row, List<Object[]> colNames, int size) {
List<Object> results = new ArrayList<>();
boolean foundError = false;
if (isEmptyRow(row, size, true)) {
Debug.logError("There are no cells to get content from!", MODULE);
return null;
}
for (int i = 0; i < size; i++) {
XSSFCell cell = null;
if (row.getPhysicalNumberOfCells() > i) {
cell = row.getCell(i);
}
if (cell == null) {
if ((Boolean) colNames.get(i)[2]) {
report.print(UtilProperties.getMessage(RESOURCE, "ErrorColCannotEmpty", new Object[]{colNames.get(i)[0]}, locale),
InterfaceReport.FORMAT_WARNING);
errorMessages.put(new CellReference(cell), UtilProperties.getMessage(RESOURCE, "ErrorColCannotEmpty",
new Object[]{colNames.get(i)[0]}, locale));
foundError = true;
continue;
} else {
cell = row.createCell(i);
}
}
CellType cellType = cell.getCellType();
String cellValue = formatter.formatCellValue(cell);
if (UtilValidate.isNotEmpty(cellValue)) {
if (cellType == CellType.FORMULA) {
cellValue = BigDecimal.valueOf(cell.getNumericCellValue()).setScale(FinAccountHelper.getDecimals(),
FinAccountHelper.getRounding()).toString();
report.print(((i == 0) ? "" : ", ") + cellValue, InterfaceReport.FORMAT_NOTE);
} else {
report.print(((i == 0) ? "" : ", ") + cellValue, InterfaceReport.FORMAT_NOTE);
}
} else {
report.print(((i == 0) ? "" : ","), InterfaceReport.FORMAT_NOTE);
}
if ((Boolean) colNames.get(i)[2] && UtilValidate.isEmpty(cellValue)) {
report.print(UtilProperties.getMessage(RESOURCE, "ErrorColCannotEmpty", new Object[]{colNames.get(i)[0]}, locale),
InterfaceReport.FORMAT_WARNING);
errorMessages.put(new CellReference(cell), UtilProperties.getMessage(RESOURCE, "ErrorColCannotEmpty",
new Object[]{colNames.get(i)[0]}, locale));
foundError = true;
results.add(null);
continue;
}
if ((Boolean) colNames.get(i)[2] && cellType != colNames.get(i)[1]) {
// String warningMessage = "";
if (colNames.get(i)[1] == CellType.STRING) {
results.add(cellValue);
} else if (colNames.get(i)[1] == CellType.NUMERIC) {
if (cell.getCellType() != CellType.STRING) {
cell.setCellType(CellType.STRING);
}
try {
results.add(BigDecimal.valueOf(Double.parseDouble(cell.getStringCellValue()))
.setScale(FinAccountHelper.getDecimals(), FinAccountHelper.getRounding()));
} catch (NumberFormatException e) {
results.add(null);
errorMessages.put(new CellReference(cell), UtilProperties.getMessage(RESOURCE, "ErrorParseValueToNumeric", locale));
}
}
} else {
if (UtilValidate.isEmpty(cellValue)) {
results.add(null);
continue;
}
if (colNames.get(i)[1] == CellType.STRING) {
if (cell.getCellType() == CellType.STRING) {
results.add(cell.getStringCellValue());
} else {
results.add(cellValue);
}
} else if (colNames.get(i)[1] == CellType.NUMERIC) {
if (cell.getCellType() == CellType.STRING) {
try {
results.add(BigDecimal.valueOf(Double.valueOf(cell.getStringCellValue())));
} catch (NumberFormatException e) {
results.add(null);
errorMessages.put(new CellReference(cell), UtilProperties.getMessage(RESOURCE, "ErrorParseValueToNumeric", locale));
}
} else if (cell.getCellType() == CellType.NUMERIC) {
try {
results.add(BigDecimal.valueOf(cell.getNumericCellValue())
.setScale(FinAccountHelper.getDecimals(), FinAccountHelper.getRounding()));
} catch (NumberFormatException e) {
results.add(null);
errorMessages.put(new CellReference(cell), UtilProperties.getMessage(RESOURCE, "ErrorParseValueToNumeric", locale));
}
} else {
try {
results.add(BigDecimal.valueOf(Double.valueOf(cellValue))
.setScale(FinAccountHelper.getDecimals(), FinAccountHelper.getRounding()));
} catch (NumberFormatException e) {
results.add(null);
errorMessages.put(new CellReference(cell), UtilProperties.getMessage(RESOURCE, "ErrorParseValueToNumeric", locale));
}
}
}
}
}
if (foundError) {
return null;
}
return results;
}