import os import pandas as pd class ExcelUtils: file_path = 'output.xlsx' @staticmethod def red_excel(): if not os.path.exists(ExcelUtils.file_path): return # 从Excel文件中读取数据 data = pd.read_excel('output.xlsx') return data @staticmethod def to_excel(data): # 将数据转换为DataFrame df = pd.DataFrame(data) # 导出到Excel文件 df.to_excel(ExcelUtils.file_path, index=False) print("导出成功!")