4 Commits

Author SHA1 Message Date
RuoYi
c600cb7ac1 升级fastjson到最新版2.0.61 2026-03-09 17:58:01 +08:00
RuoYi
6a074c8832 update deprecated 2026-03-09 17:57:51 +08:00
RuoYi
fefad4e147 update userid default value 2026-03-09 17:57:03 +08:00
RuoYi
316117524d 优化Excel自定义格式样式重复创建问题 2026-03-09 15:14:51 +08:00
3 changed files with 15 additions and 3 deletions

View File

@@ -28,7 +28,7 @@
<dynamic-ds.version>4.3.1</dynamic-ds.version>
<commons.io.version>2.21.0</commons.io.version>
<velocity.version>2.3</velocity.version>
<fastjson.version>2.0.60</fastjson.version>
<fastjson.version>2.0.61</fastjson.version>
<jjwt.version>0.9.1</jjwt.version>
<minio.version>8.2.2</minio.version>
<poi.version>4.1.2</poi.version>

View File

@@ -53,7 +53,7 @@ public class SecurityContextHolder
public static Long getUserId()
{
return Convert.toLong(get(SecurityConstants.DETAILS_USER_ID), 0L);
return Convert.toLong(get(SecurityConstants.DETAILS_USER_ID), null);
}
public static void setUserId(String account)

View File

@@ -79,6 +79,11 @@ public class ExcelUtil<T>
public static final String[] FORMULA_STR = { "=", "-", "+", "@" };
/**
* 单元格样式缓存
*/
private Map<String, CellStyle> cellStyleCache = new HashMap<String, CellStyle>();
/**
* Excel sheet最大行数默认65536
*/
@@ -976,7 +981,7 @@ public class ExcelUtil<T>
* 添加单元格
*/
@SuppressWarnings("deprecation")
public Cell addCell(Excel attr, Row row, T vo, Field field, int column)
public Cell addCell(Excel attr, Row row, T vo, Field field, int column)
{
Cell cell = null;
try
@@ -1043,9 +1048,16 @@ public class ExcelUtil<T>
*/
private CellStyle createCellStyle(CellStyle cellStyle, String format)
{
String key = cellStyle.getIndex() + "|" + format;
CellStyle cached = cellStyleCache.get(key);
if (cached != null)
{
return cached;
}
CellStyle style = wb.createCellStyle();
style.cloneStyleFrom(cellStyle);
style.setDataFormat(wb.getCreationHelper().createDataFormat().getFormat(format));
cellStyleCache.put(key, style);
return style;
}