1.遇到的問題
1.1、給帶公式的excel寫入資料,檔案未儲存狀態,讀值為None。
解決方式1:
from win32com.client import Dispatch # 使用win32com自動開啟檔案並儲存 def just_open(filename): xlApp = Dispatch("Excel.Application") xlApp.Visible = False xlBook = xlApp.Workbooks.Open(filename) xlBook.Save() xlBook.Close() xlsx_name = r"D:\zmm\PC\PC_AT\performance.xlsx" just_open(xlsx_name) wb = load_workbook(xlsx_name, data_only=True) ws = wb['spec'] cell = ws["F60"] print(cell.value)