from __future__ import annotations

from pathlib import Path

from openpyxl import load_workbook


ROOT = Path(__file__).resolve().parents[1]
EXCEL_PATH = ROOT / "测试用例" / "SaaS_订阅邀请登录_测试功能点.xlsx"
SHEET_NAME = "流程用例-产品解决方案"


def main() -> None:
    wb = load_workbook(EXCEL_PATH, read_only=True)
    ws = wb[SHEET_NAME]
    bad_patterns = ["按页面实际规则", "不再展示为已上架", "发布后下架"]
    bad_rows: list[str] = []
    for row in ws.iter_rows(values_only=True):
        text = " ".join(str(value) for value in row if value is not None)
        if any(pattern in text for pattern in bad_patterns):
            bad_rows.append(text)

    print(f"rows={ws.max_row} cols={ws.max_column}")
    for row in ws.iter_rows(min_row=2, values_only=True):
        print(f"{row[0]} {row[2]}")
    print(f"bad={len(bad_rows)}")


if __name__ == "__main__":
    main()
