value(Cell) 수정

master
mjkhan21 6 months ago
parent b28b3022e8
commit 42d27c1354

@ -11,14 +11,9 @@ import java.util.stream.Stream;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.DateUtil;
public class XLSReader extends XLS {
private boolean numAsDate;
public XLSReader setNumberAsDate(boolean asDate) {
numAsDate = asDate;
return this;
}
import cokr.xit.foundation.util.DateFormats;
public class XLSReader extends XLS {
public XLSReader open(InputStream input) {
load(input);
return this;
@ -58,12 +53,14 @@ public class XLSReader extends XLS {
return row(row).col(col);
}
private static final DateFormats dateFormats = new DateFormats();
public String value(Cell cell) {
return switch (cell.getCellType()) {
case STRING -> cell.getStringCellValue();
case NUMERIC -> numAsDate && DateUtil.isCellDateFormatted(cell) ?
cell.getDateCellValue().toString() :
String.valueOf(cell.getNumericCellValue());
case NUMERIC -> !DateUtil.isCellDateFormatted(cell) ?
String.valueOf(cell.getNumericCellValue()) :
dateFormats.format("yyyy-MM-dd HH:mm:ss", cell.getDateCellValue());
case BOOLEAN -> String.valueOf(cell.getBooleanCellValue());
case FORMULA -> cell.getCellFormula();
default -> "";

Loading…
Cancel
Save