This commit is contained in:
Looly
2019-10-29 19:05:23 +08:00
parent 3cef7fa9a7
commit bf03aebcef
107 changed files with 283 additions and 456 deletions

View File

@@ -792,7 +792,7 @@ public class ExcelWriter extends ExcelBase<ExcelWriter> {
* @see #writeRow(Map, boolean)
* @since 4.1.5
*/
@SuppressWarnings({"rawtypes" })
@SuppressWarnings({"rawtypes", "unchecked"})
public ExcelWriter writeRow(Object rowBean, boolean isWriteKeyAsHead) {
if (rowBean instanceof Iterable) {
return writeRow((Iterable<?>) rowBean);
@@ -806,7 +806,7 @@ public class ExcelWriter extends ExcelBase<ExcelWriter> {
}
} else if (BeanUtil.isBean(rowBean.getClass())) {
if (MapUtil.isEmpty(this.headerAlias)) {
rowMap = BeanUtil.beanToMap(rowBean, new LinkedHashMap<String, Object>(), false, false);
rowMap = BeanUtil.beanToMap(rowBean, new LinkedHashMap<>(), false, false);
} else {
// 别名存在情况下按照别名的添加顺序排序Bean数据
rowMap = BeanUtil.beanToMap(rowBean, new TreeMap<>(getInitedAliasComparator()), false, false);
@@ -1018,7 +1018,7 @@ public class ExcelWriter extends ExcelBase<ExcelWriter> {
final Map<Object, Object> filteredMap = new LinkedHashMap<>();
String aliasName;
for (Entry<?, ?> entry : rowMap.entrySet()) {
aliasName = this.headerAlias.get(entry.getKey());
aliasName = this.headerAlias.get(StrUtil.toString(entry.getKey()));
if (null != aliasName) {
// 别名键值对加入
filteredMap.put(aliasName, entry.getValue());

View File

@@ -25,7 +25,7 @@ public enum CellDataType {
NULL("");
/** 属性值 */
private String name;
private final String name;
/**
* 构造

View File

@@ -149,6 +149,7 @@ public class ExcelSaxUtil {
// 普通数字
if (null != numFmtString && numFmtString.indexOf(StrUtil.C_DOT) < 0) {
final long longPart = (long) numValue;
//noinspection RedundantIfStatement
if (longPart == numValue) {
// 对于无小数部分的数字类型转为Long
return longPart;

View File

@@ -184,9 +184,6 @@ public class StyleUtil {
* @since 4.6.3
*/
public static boolean isNullOrDefaultStyle(Workbook workbook, CellStyle style) {
if(null == style || style.equals(workbook.getCellStyleAt(0))) {
return true;
}
return false;
return (null == style) || style.equals(workbook.getCellStyleAt(0));
}
}