From c542b7ac32793d0338c64e26614902cd2840e8e1 Mon Sep 17 00:00:00 2001
From: 也曾为你、像超人 <1553592282@qq.com>
Date: Sat, 01 Oct 2022 07:06:10 +0800
Subject: [PATCH] 解决导出时包含空子列表数据异常的问题
---
ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java | 11 +++++++----
1 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java
index 69f7eed..d687641 100644
--- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java
+++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java
@@ -699,6 +699,11 @@
subList = getListCellValue(vo);
subMergedLastRowNum = subMergedLastRowNum + subList.size();
}
+ else
+ {
+ subMergedFirstRowNum++;
+ subMergedLastRowNum++;
+ }
int column = 0;
for (Object[] os : fields)
@@ -808,7 +813,6 @@
if (!headerStyles.containsKey(key))
{
CellStyle style = wb.createCellStyle();
- style = wb.createCellStyle();
style.cloneStyleFrom(styles.get("data"));
style.setAlignment(HorizontalAlignment.CENTER);
style.setVerticalAlignment(VerticalAlignment.CENTER);
@@ -842,7 +846,6 @@
if (!styles.containsKey(key))
{
CellStyle style = wb.createCellStyle();
- style = wb.createCellStyle();
style.setAlignment(excel.align());
style.setVerticalAlignment(VerticalAlignment.CENTER);
style.setBorderRight(BorderStyle.THIN);
@@ -993,7 +996,7 @@
{
// 创建cell
cell = row.createCell(column);
- if (isSubListValue(vo) && attr.needMerge())
+ if (isSubListValue(vo) && getListCellValue(vo).size() > 1 && attr.needMerge())
{
CellRangeAddress cellAddress = new CellRangeAddress(subMergedFirstRowNum, subMergedLastRowNum, column, column);
sheet.addMergedRegion(cellAddress);
@@ -1020,7 +1023,7 @@
}
else if (value instanceof BigDecimal && -1 != attr.scale())
{
- cell.setCellValue((((BigDecimal) value).setScale(attr.scale(), attr.roundingMode())).toString());
+ cell.setCellValue((((BigDecimal) value).setScale(attr.scale(), attr.roundingMode())).doubleValue());
}
else if (!attr.handler().equals(ExcelHandlerAdapter.class))
{
--
Gitblit v1.9.2