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