文件
yjyf/tests/recalc_com.py
MiAn 3ebd795cbb feat(ui): 新增/优化界面样式、图标及交互组件
- 新增多个功能图标(箭头、盾牌、位置等)
- 优化全局按钮、标签、输入框等组件样式
- 修复导航栏高度计算逻辑,适配微信小程序
- 优化消息页、订单页、个人中心等页面布局
- 修复微信支付配置及通知接口问题
2026-11-09 09:57:22 +08:00

33 行
1.2 KiB
Python

# -*- coding: utf-8 -*-
"""用 Excel COM 重算公式并扫描公式错误"""
import win32com.client
import os
path = r"D:\Projects\phpstudy_pro\WWW\yjyf\doc\测试用例-全系统.xlsx"
excel = win32com.client.DispatchEx("Excel.Application")
excel.Visible = False
excel.DisplayAlerts = False
try:
wb = excel.Workbooks.Open(path)
excel.CalculateFullRebuild()
errors = []
for ws in wb.Worksheets:
used = ws.UsedRange
for row in range(1, used.Rows.Count + 1):
for col in range(1, used.Columns.Count + 1):
v = ws.Cells(row, col).Text
if v.startswith("#") and any(e in v for e in ("REF!", "DIV/0!", "VALUE!", "N/A", "NAME?")):
errors.append(f"{ws.Name}!{ws.Cells(row, col).Address}={v}")
print("formula errors:", len(errors))
for e in errors[:10]:
print(" -", e)
# 抽查统计 sheet 计算值
ws2 = wb.Worksheets("用例统计")
last = ws2.Cells(ws2.UsedRange.Rows.Count, 1).Row
print(f"用例统计合计行: 用例数={ws2.Cells(last,2).Value} 通过={ws2.Cells(last,3).Value} 失败={ws2.Cells(last,4).Value}")
wb.Save()
wb.Close(False)
finally:
excel.Quit()
print("done")