# -*- coding: utf-8 -*- # 临时脚本:导出xlsx逐格+合并区诊断 import zipfile, re, sys z = zipfile.ZipFile(sys.argv[1]) s = z.read("xl/worksheets/sheet1.xml").decode("utf-8") rows = re.findall(r']*>(.*?)', s, re.S) for rn, body in rows: cells = re.findall(r']*)(?:/>|>(.*?))', body, re.S) vals = [] for ref, attr, inner in cells: m = re.findall(r']*>([^<]*)|([^<]*)', inner) v = " ".join(a or b for a, b in m) st = re.search(r's="(\d+)"', attr) vals.append(ref + ("[s" + st.group(1) + "]" if st else "") + "=" + v) print(rn, "|", " ; ".join(vals)) print("MERGES:", re.findall(r'