updated libraries

This commit is contained in:
Joern Muehlencord
2021-02-21 16:30:23 +01:00
parent b129228b36
commit cd2e3b0642
5 changed files with 103 additions and 105 deletions

View File

@ -255,8 +255,28 @@ public abstract class PoiUtil {
}
}
public static int getIntegerValue(Row currentRow, int cellNumber) throws PoiException {
return getIntegerValue(currentRow, cellNumber, false, 0);
}
public static Integer getIntegerValue(Row currentRow, int cellNumber, boolean returnDefaultValue, Integer defaultValue) throws PoiException {
if (currentRow == null) {
throw new PoiException("Current row must not be null");
}
Cell cell = currentRow.getCell(cellNumber);
if ((PoiUtil.cellEmpty(cell)) && !returnDefaultValue) {
throw new PoiException("Cannot read cell " + cellNumber + " from row " + currentRow.getRowNum());
} else {
if (PoiUtil.cellEmpty(cell)) {
return defaultValue;
} else {
return Double.valueOf(cell.getNumericCellValue()).intValue();
}
}
}
/**
* remove charecters which often cause troubles in other applications - e.g. em dash (long dash) is created by Excel automatically
* remove characters which often cause troubles in other applications - e.g. em dash (long dash) is created by Excel automatically
*
* @param sourceValue the input string to execute the replacement
* @return sourceValue with replaced characters