|
|
|
@ -86,8 +86,7 @@ public class XLSWriter extends XLS {
|
|
|
|
|
if (!isEmpty(t)) {
|
|
|
|
|
int c = cell.getColumnIndex();
|
|
|
|
|
if (isEmpty(objs)) {
|
|
|
|
|
if (t instanceof Map) {
|
|
|
|
|
Map<?, ?> map = (Map<?, ?>)t;
|
|
|
|
|
if (t instanceof Map<?, ?> map) {
|
|
|
|
|
objs = map.keySet().stream().map(v -> (Object)v).toList();
|
|
|
|
|
} else if (t instanceof Iterable) {
|
|
|
|
|
objs = (Iterable<Object>)t;
|
|
|
|
@ -103,15 +102,15 @@ public class XLSWriter extends XLS {
|
|
|
|
|
|
|
|
|
|
Object val = null;
|
|
|
|
|
Format format = null;
|
|
|
|
|
if (obj instanceof Format)
|
|
|
|
|
format = (Format)obj;
|
|
|
|
|
if (obj instanceof Format fmt)
|
|
|
|
|
format = fmt;
|
|
|
|
|
|
|
|
|
|
if (format != null)
|
|
|
|
|
val = format.value(t);
|
|
|
|
|
else {
|
|
|
|
|
Object key = Format.getKey(obj);
|
|
|
|
|
if (key != null && t instanceof Map)
|
|
|
|
|
val = ((Map<?, ?>)t).get(key);
|
|
|
|
|
if (key != null && t instanceof Map<?, ?> map)
|
|
|
|
|
val = map.get(key);
|
|
|
|
|
else
|
|
|
|
|
val = obj;
|
|
|
|
|
}
|
|
|
|
@ -253,18 +252,16 @@ public class XLSWriter extends XLS {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
boolean setCellValue(Object val) {
|
|
|
|
|
if (val instanceof String) {
|
|
|
|
|
cell.setCellValue((String)val);
|
|
|
|
|
if (val instanceof String str) {
|
|
|
|
|
cell.setCellValue(str);
|
|
|
|
|
return true;
|
|
|
|
|
} else if (val instanceof Number) {
|
|
|
|
|
Number number = (Number)val;
|
|
|
|
|
} else if (val instanceof Number number) {
|
|
|
|
|
cell.setCellValue(number.doubleValue());
|
|
|
|
|
return true;
|
|
|
|
|
} else if (val instanceof Date) {
|
|
|
|
|
cell.setCellValue((Date)val);
|
|
|
|
|
} else if (val instanceof Date date) {
|
|
|
|
|
cell.setCellValue(date);
|
|
|
|
|
return true;
|
|
|
|
|
} else if (val instanceof Boolean) {
|
|
|
|
|
Boolean b = (Boolean)val;
|
|
|
|
|
} else if (val instanceof Boolean b) {
|
|
|
|
|
cell.setCellValue(b.booleanValue());
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
@ -284,12 +281,12 @@ public class XLSWriter extends XLS {
|
|
|
|
|
|
|
|
|
|
void setCellStyle(Object obj) {
|
|
|
|
|
CellStyle cellStyle = null;
|
|
|
|
|
if (obj instanceof Format)
|
|
|
|
|
cellStyle = ((Format)obj).style();
|
|
|
|
|
else if (obj instanceof Style)
|
|
|
|
|
cellStyle = cellStyle((Style)obj);
|
|
|
|
|
else if (obj instanceof CellStyle)
|
|
|
|
|
cellStyle = (CellStyle)obj;
|
|
|
|
|
if (obj instanceof Format format)
|
|
|
|
|
cellStyle = format.style();
|
|
|
|
|
else if (obj instanceof Style style)
|
|
|
|
|
cellStyle = cellStyle(style);
|
|
|
|
|
else if (obj instanceof CellStyle style)
|
|
|
|
|
cellStyle = style;
|
|
|
|
|
|
|
|
|
|
if (cellStyle != null)
|
|
|
|
|
cell.setCellStyle(cellStyle);
|
|
|
|
|