io.github.sinri.keel.poi.excel.entity.KeelSheetMatrixRow Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of Keel Show documentation
Show all versions of Keel Show documentation
A website framework with VERT.X for ex-PHP-ers, exactly Ark Framework Users.
The newest version!
package io.github.sinri.keel.poi.excel.entity;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.math.BigDecimal;
import java.util.List;
/**
* It is designed to be overridden for customized row reader.
*
* @since 3.0.14
* @since 3.0.18 Finished Technical Preview.
* @since 3.1.1 Use BigDecimal to handle the number value of cells.
*/
public class KeelSheetMatrixRow {
private final List rawRow;
public KeelSheetMatrixRow(List rawRow) {
this.rawRow = rawRow;
}
@Nonnull
public String readValue(int i) {
return rawRow.get(i);
}
/**
* @since 3.1.1
*/
public BigDecimal readValueToBigDecimal(int i) {
return new BigDecimal(readValue(i));
}
/**
* @since 3.1.1
*/
public BigDecimal readValueToBigDecimalStrippedTrailingZeros(int i) {
return new BigDecimal(readValue(i)).stripTrailingZeros();
}
@Nullable
public Integer readValueToInteger(int i) {
try {
return readValueToBigDecimal(i).intValueExact();
} catch (ArithmeticException arithmeticException) {
return null;
}
// double v = readValueToDouble(i);
// return (int) v;
}
@Nullable
public Long readValueToLong(int i) {
try {
return readValueToBigDecimal(i).longValueExact();
} catch (ArithmeticException arithmeticException) {
return null;
}
// double v = readValueToDouble(i);
// return (long) v;
}
public double readValueToDouble(int i) {
return readValueToBigDecimal(i).doubleValue();
// return Double.parseDouble(readValue(i));
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy