fs-lawrisk/tools/inspect_sheets.py

16 lines
421 B
Python
Raw Permalink Normal View History

import pandas as pd
import sys
sys.stdout = open('excel_sheets.txt', 'w', encoding='utf-8')
try:
xl = pd.ExcelFile('主题-事项绑定.xlsx')
print("Sheet names:", xl.sheet_names)
for sheet in xl.sheet_names:
print(f"\n--- Sheet: {sheet} ---")
df = pd.read_excel(xl, sheet_name=sheet, header=None, nrows=5)
print(df.to_string())
except Exception as e:
print(f"Error: {e}")