excel-multi-sheet-dynamic-analysis
Installation
SKILL.md
Step1 遍历所有sheet,灵活定位目标列并统计特定类型字段的数量。
target_col_keyword = 'type' # 占位示例
target_val_keyword = 'varchar' # 占位示例
total_target_count = 0
target_details = []
for sheet_name in wb.sheetnames:
ws = wb[sheet_name]
raw_data = list(ws.iter_rows(values_only=True))
# 实用技巧:灵活策略定位目标列,通过扫描前几行数据内容定位表头行
header_row_idx = None
for i, row in enumerate(raw_data):
if any(cell and isinstance(cell, str) and target_col_keyword in str(cell).lower() for cell in row):
header_row_idx = i
break