XLSReader 추가(진행 중)
parent
a765f9f288
commit
858a3fdb95
@ -0,0 +1,60 @@
|
||||
package cokr.xit.base.docs.xls;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
import org.apache.poi.ss.usermodel.DateUtil;
|
||||
|
||||
public class XLSReader extends XLS {
|
||||
public XLSReader open(InputStream input) {
|
||||
load(input);
|
||||
return this;
|
||||
}
|
||||
|
||||
public XLSReader open(File file) {
|
||||
load(file);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public XLSReader worksheet(int index) {
|
||||
super.worksheet(index);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public XLSReader worksheet(String name) {
|
||||
super.worksheet(name);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public XLSReader row(int index) {
|
||||
super.row(index);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public XLSReader col(int index) {
|
||||
super.col(index);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public XLSReader cell(int row, int col) {
|
||||
return row(row).col(col);
|
||||
}
|
||||
|
||||
public String valueOf(Cell cell) {
|
||||
return switch (cell.getCellType()) {
|
||||
case STRING -> cell.getStringCellValue();
|
||||
case NUMERIC -> DateUtil.isCellDateFormatted(cell) ?
|
||||
cell.getDateCellValue().toString() :
|
||||
String.valueOf(cell.getNumericCellValue());
|
||||
case BOOLEAN -> String.valueOf(cell.getBooleanCellValue());
|
||||
case FORMULA -> cell.getCellFormula();
|
||||
default -> "";
|
||||
};
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue