| 12345678910111213141516 |
- # -*- 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'<row r="(\d+)"[^>]*>(.*?)</row>', s, re.S)
- for rn, body in rows:
- cells = re.findall(r'<c r="([A-Z]+\d+)"([^/>]*)(?:/>|>(.*?)</c>)', body, re.S)
- vals = []
- for ref, attr, inner in cells:
- m = re.findall(r'<t[^>]*>([^<]*)</t>|<v>([^<]*)</v>', 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'<mergeCell ref="([^"]+)"', s))
|