From 277b5047d00a3e9094bafd5ecb078976fbf6a92d Mon Sep 17 00:00:00 2001
From: yaowanxin <3588231647@qq.com>
Date: 星期四, 08 一月 2026 18:59:04 +0800
Subject: [PATCH] 华玺砂浆转移-采购代码、发货和发货审核、报修和报修审核、采购模板,查询采购模板接口、财务管理的存货核算数据接口、财务管理的固定资产核算获取台账接口、采购审批,接口、客户分类字段、采购台账字段,实现采购异常记录的添加接口、黑名单,添加资质管理字段,可上传资质文件-至军泰伟业
---
src/main/java/com/ruoyi/common/utils/excel/ExcelUtils.java | 35 ++++++++++++++++++++++++++++++++---
1 files changed, 32 insertions(+), 3 deletions(-)
diff --git a/src/main/java/com/ruoyi/common/utils/excel/ExcelUtils.java b/src/main/java/com/ruoyi/common/utils/excel/ExcelUtils.java
index d1c23ed..230bb77 100644
--- a/src/main/java/com/ruoyi/common/utils/excel/ExcelUtils.java
+++ b/src/main/java/com/ruoyi/common/utils/excel/ExcelUtils.java
@@ -843,18 +843,47 @@
} else {
merge = false;
if (x1 > 0) {
- sheet.addMergedRegion(new CellRangeAddress((x1 - 1), x2, y, y));
+ // 妫�鏌ユ槸鍚︿笌鐜版湁鍚堝苟鍖哄煙閲嶅彔锛屽鏋滄湁鍒欏垹闄ゆ棫鍖哄煙锛屽啀鍚堝苟鏂板尯鍩�
+ CellRangeAddress newRegion = new CellRangeAddress((x1 - 1), x2, y, y);
+ handleOverlappingRegions(sheet, newRegion);
}
x1 = 0;
x2 = 0;
}
}
if (x1 > 0) {
- sheet.addMergedRegion(new CellRangeAddress((x1 - 1), x2, y, y));
+ // 妫�鏌ユ槸鍚︿笌鐜版湁鍚堝苟鍖哄煙閲嶅彔锛屽鏋滄湁鍒欏垹闄ゆ棫鍖哄煙锛屽啀鍚堝苟鏂板尯鍩�
+ CellRangeAddress newRegion = new CellRangeAddress((x1 - 1), x2, y, y);
+ handleOverlappingRegions(sheet, newRegion);
}
}
}
-
+
+ /**
+ * 妫�鏌ユ槸鍚︿笌鐜版湁鍚堝苟鍖哄煙閲嶅彔锛屽鏋滄湁鍒欏垹闄ゆ棫鍖哄煙锛屽啀鍚堝苟鏂板尯鍩�
+ * @param sheet Excel宸ヤ綔琛�
+ * @param newRegion 鏂扮殑鍚堝苟鍖哄煙
+ */
+ private static void handleOverlappingRegions(Sheet sheet, CellRangeAddress newRegion) {
+ // 绉婚櫎閲嶅彔鐨勭幇鏈夊尯鍩�
+ List<CellRangeAddress> overlappingRegions = new ArrayList<>();
+ for (int i = sheet.getNumMergedRegions() - 1; i >= 0; i--) {
+ CellRangeAddress existingRegion = sheet.getMergedRegion(i);
+ if (newRegion.intersects(existingRegion)) {
+ overlappingRegions.add(existingRegion);
+ sheet.removeMergedRegion(i);
+ }
+ }
+ // 鍚堝苟鍒版柊鍖哄煙锛堣繖閲岀畝鍗曞湴灏嗗畠浠坊鍔犲埌鏂扮殑鍚堝苟鍖哄煙鍒楄〃涓紝瀹為檯搴旂敤涓彲鑳介渶瑕佹洿澶嶆潅鐨勯�昏緫鏉ョ湡姝b�滃悎骞垛�濆尯鍩燂級
+ // 娉ㄦ剰锛歅OI鐨凜ellRangeAddress娌℃湁鎻愪緵鐩存帴鍚堝苟涓や釜鍖哄煙鐨勬柟娉曪紝鎵�浠ヨ繖閲屽彧鏄ず渚�
+ // 濡傛灉闇�瑕佺湡姝g殑鍚堝苟锛屽彲鑳介渶瑕佽嚜瀹氫箟閫昏緫鏉ヨ绠楁柊鐨勮竟鐣�
+ for (CellRangeAddress overlappingRegion : overlappingRegions) {
+ sheet.addMergedRegion(overlappingRegion);
+ }
+ sheet.addMergedRegion(newRegion);
+ }
+
+
private static void write(HttpServletResponse response, SXSSFWorkbook book, String fileName) throws IOException {
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setCharacterEncoding("utf-8");
--
Gitblit v1.9.3