org.sfm.poi.impl.PoiDoubleGetter Maven / Gradle / Ivy
package org.sfm.poi.impl;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.sfm.reflect.Getter;
import org.sfm.reflect.primitive.DoubleGetter;
public class PoiDoubleGetter implements Getter, DoubleGetter {
private final int index;
public PoiDoubleGetter(int index) {
this.index = index;
}
@Override
public Double get(Row target) throws Exception {
final Cell cell = target.getCell(index);
if (cell != null && cell.getCellType() != Cell.CELL_TYPE_BLANK) {
return cell.getNumericCellValue();
} else {
return null;
}
}
@Override
public double getDouble(Row target) throws Exception {
final Cell cell = target.getCell(index);
if (cell != null) {
return cell.getNumericCellValue();
} else {
return 0;
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy