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}")
