| 123456789101112131415 |
- # -*- 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, inner in cells:
- m = re.findall(r'<t[^>]*>([^<]*)</t>|<v>([^<]*)</v>', inner)
- v = " ".join(a or b for a, b in m)
- if v:
- vals.append(ref + "=" + v)
- print(rn, "|", " ; ".join(vals))
|