From afed4dfc3b1b79ba1beec26e68a1ba6ac1192c15 Mon Sep 17 00:00:00 2001
From: zhizhijie <zhizhijie@users.noreply.gitee.com>
Date: 星期四, 17 九月 2026 14:39:59 +0800
Subject: [PATCH] fix(投资): 修复两级表头导致的取列错位 + 新增《弹窗提示》机制(14 条规则)
---
docs/投资/工具/格式探测.py | 39 +++++++++++++++++++++++++++++++++++++++
1 files changed, 39 insertions(+), 0 deletions(-)
diff --git "a/docs/\346\212\225\350\265\204/\345\267\245\345\205\267/\346\240\274\345\274\217\346\216\242\346\265\213.py" "b/docs/\346\212\225\350\265\204/\345\267\245\345\205\267/\346\240\274\345\274\217\346\216\242\346\265\213.py"
index 1f2cac8..f23585c 100644
--- "a/docs/\346\212\225\350\265\204/\345\267\245\345\205\267/\346\240\274\345\274\217\346\216\242\346\265\213.py"
+++ "b/docs/\346\212\225\350\265\204/\345\267\245\345\205\267/\346\240\274\345\274\217\346\216\242\346\265\213.py"
@@ -106,6 +106,45 @@
return n - 1
+def sheet_merges(path):
+ """杩斿洖 {sheet_name: [(rlo, rhi, clo, chi), ...]}锛�0 鍩恒�佸彸寮�锛夈��
+
+ 鐢ㄤ簬璇嗗埆銆屼袱绾ц〃澶淬�嶏細缁勮〃澶达紙璺ㄥ鍒楃殑鍚堝苟鍗曞厓鏍硷級涓嶈兘鐩存帴褰撴垚鏌愬瓧娈电殑鍒椼��
+ 璇讳笉鍒板悎骞朵俊鎭椂杩斿洖宸茶В鏋愬埌鐨勯儴鍒嗭紙涓嶆姏寮傚父锛夈��
+ """
+ with open(path, 'rb') as fh:
+ magic = fh.read(4)
+ out = {}
+ try:
+ if magic[:4] == b'PK\x03\x04':
+ if openpyxl is None:
+ return out
+ wb = openpyxl.load_workbook(path, data_only=True)
+ for nm in wb.sheetnames:
+ ws = wb[nm]
+ out[nm] = [(r.min_row - 1, r.max_row, r.min_col - 1, r.max_col)
+ for r in ws.merged_cells.ranges]
+ wb.close()
+ else:
+ if xlrd is None:
+ return out
+ bk = xlrd.open_workbook(path, formatting_info=True)
+ for si in range(bk.nsheets):
+ sh = bk.sheet_by_index(si)
+ out[sh.name] = list(getattr(sh, 'merged_cells', []) or [])
+ except Exception:
+ return out
+ return out
+
+
+def merge_span(merges, row1, col0):
+ """璇ュ崟鍏冩牸锛�1 鍩鸿鍙枫��0 鍩哄垪鍙凤級鎵�鍦ㄥ悎骞跺尯鐨� (鍒�0璧�, 鍒�0姝㈠彸寮�)锛涗笉鍦ㄥ悎骞跺尯杩斿洖 None銆�"""
+ for (rlo, rhi, clo, chi) in (merges or ()):
+ if rlo <= row1 - 1 < rhi and clo <= col0 < chi:
+ return (clo, chi)
+ return None
+
+
def open_sheets(path):
"""杩斿洖 [(sheet_name, nrows, ncols, cell_fn), ...]銆�
--
Gitblit v1.9.1