|
|
|
@ -5,6 +5,7 @@ import org.apache.poi.ss.usermodel.CellStyle;
|
|
|
|
|
import org.apache.poi.ss.usermodel.Font;
|
|
|
|
|
import org.apache.poi.ss.usermodel.Workbook;
|
|
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.time.temporal.ChronoUnit;
|
|
|
|
|
import java.time.temporal.Temporal;
|
|
|
|
|
import java.time.temporal.TemporalField;
|
|
|
|
@ -37,7 +38,11 @@ public class PoiUtils {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static int convertCellType(Class<?> valueClass) {
|
|
|
|
|
public static int convertCellType(Object value) {
|
|
|
|
|
if (value == null) {
|
|
|
|
|
return Cell.CELL_TYPE_BLANK;
|
|
|
|
|
}
|
|
|
|
|
Class<?> valueClass = value.getClass();
|
|
|
|
|
if (valueClass.isPrimitive()) {
|
|
|
|
|
valueClass = PRIMITIVE_CLASSES.get(valueClass);
|
|
|
|
|
}
|
|
|
|
@ -54,12 +59,15 @@ public class PoiUtils {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void setCellValue(Cell cell, Object value) {
|
|
|
|
|
if (value == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
Class valueClass = value.getClass();
|
|
|
|
|
if (valueClass.isPrimitive()) {
|
|
|
|
|
valueClass = PRIMITIVE_CLASSES.get(valueClass);
|
|
|
|
|
}
|
|
|
|
|
if (Number.class.isAssignableFrom(valueClass)) {
|
|
|
|
|
cell.setCellValue((double) value);
|
|
|
|
|
cell.setCellValue(((Number)value).doubleValue());
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (Date.class.isAssignableFrom(valueClass)) {
|
|
|
|
|