import zipfile, re, xml.etree.ElementTree as ET
from pathlib import Path
p=Path('/Users/neo/.hermes/audits/cashflow-asset-hook-20260512-083049/wanchuan_anhui_v9_v2_1_long_asset_R29_R169_asset_schedule_atomic_SAFE_20260513-092323.xlsx')
with zipfile.ZipFile(p) as z:
    styles=z.read('xl/styles.xml').decode('utf-8')
    m=re.search(r'<cellXfs\b[^>]*count="(\d+)"', styles); count=int(m.group(1))
    xml=z.read('xl/worksheets/sheet26.xml').decode('utf-8')
    bad=[]
    for cm in re.finditer(r'<c\b([^>]*)', xml):
        attrs=cm.group(1); rm=re.search(r'r="([A-Z]+\d+)"',attrs); sm=re.search(r's="(\d+)"',attrs)
        if sm and int(sm.group(1))>=count:
            bad.append((rm.group(1) if rm else '?', sm.group(1)))
    print('cellXfs count',count,'bad style refs',bad[:20], 'count',len(bad))
