Files
dsProject/dsLightRag/Test/T1_RW_Excel.py
2025-08-14 15:45:08 +08:00

15 lines
506 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from openpyxl import load_workbook
excel_file = r'D:\dsWork\dsProject\dsLightRag\Doc\T1、史校长资料\测试结果\100题测试结果.xlsx'
# 1、利用EXCEL工具读取O1的内容
wb = load_workbook(excel_file)
ws = wb.active # 获取第一个sheet
O1_content = ws['O1'].value # 获取O1单元格内容
print(f"O1单元格内容为: {O1_content}")
# 2、写入示例
ws['O1'] = "【理想】召回文本" # 修改O1单元格内容
wb.save(excel_file) # 保存修改
wb.close()