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