From d39e4f7d839167c16425086dfa2f8747bccfdff9 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期四, 05 十一月 2026 17:39:01 +0800
Subject: [PATCH] feat: 打通销售采购财务闭环并完成累计业务优化

---
 yudao-framework/yudao-spring-boot-starter-excel/src/main/java/cn/iocoder/yudao/framework/excel/core/handler/ColumnWidthMatchStyleStrategy.java |   23 ++++++++++++++++++++++-
 1 files changed, 22 insertions(+), 1 deletions(-)

diff --git a/yudao-framework/yudao-spring-boot-starter-excel/src/main/java/cn/iocoder/yudao/framework/excel/core/handler/ColumnWidthMatchStyleStrategy.java b/yudao-framework/yudao-spring-boot-starter-excel/src/main/java/cn/iocoder/yudao/framework/excel/core/handler/ColumnWidthMatchStyleStrategy.java
index 3ed512d..69100bf 100644
--- a/yudao-framework/yudao-spring-boot-starter-excel/src/main/java/cn/iocoder/yudao/framework/excel/core/handler/ColumnWidthMatchStyleStrategy.java
+++ b/yudao-framework/yudao-spring-boot-starter-excel/src/main/java/cn/iocoder/yudao/framework/excel/core/handler/ColumnWidthMatchStyleStrategy.java
@@ -59,10 +59,31 @@
         }
     }
 
+    /** 鎸� Excel 鍒楀浼拌琛ㄥご锛氫腑鏃ラ煩瀹藉瓧绗﹀崰涓ゆ牸锛屽苟涓鸿竟璺濈暀鍑虹┖闂淬�� */
+    private int headerWidth(String text) {
+        int widest = 0;
+        int line = 0;
+        for (int offset = 0; offset < text.length();) {
+            int cp = text.codePointAt(offset);
+            offset += Character.charCount(cp);
+            if (cp == '\n' || cp == '\r') {
+                widest = Math.max(widest, line);
+                line = 0;
+                continue;
+            }
+            Character.UnicodeScript script = Character.UnicodeScript.of(cp);
+            boolean wide = script == Character.UnicodeScript.HAN || script == Character.UnicodeScript.HIRAGANA
+                    || script == Character.UnicodeScript.KATAKANA || script == Character.UnicodeScript.HANGUL
+                    || (cp >= 0xff01 && cp <= 0xff60) || (cp >= 0xffe0 && cp <= 0xffe6);
+            line += wide ? 2 : 1;
+        }
+        return Math.max(widest, line);
+    }
+
     @SuppressWarnings("EnhancedSwitchMigration")
     private Integer dataLength(List<WriteCellData<?>> cellDataList, Cell cell, Boolean isHead) {
         if (isHead) {
-            return cell.getStringCellValue().getBytes().length;
+            return Math.max(12, headerWidth(cell.getStringCellValue()) + 3);
         }
         WriteCellData<?> cellData = cellDataList.get(0);
         CellDataTypeEnum type = cellData.getType();

--
Gitblit v1.9.3