Openpyxl观察一张纸的max_row?

时间:2018-06-13 07:53:25

标签: python openpyxl observer-pattern observers

是否可以观察纸张的最大行是否有变化?我有一些函数,我想在每次更新值时运行它们(它们将是观察者)。

openpyxl支持吗?

1 个答案:

答案 0 :(得分:0)

from openpyxl import Workbook
from openpyxl import load_workbook

wb = load_workbook('yourFile.xlsx')
ws = wb['Sheet1']

initial_max_value = ws.max_row

while ws.max_row == inital_max_value:
  THE 
   CODE 
   YOU 
  WANT TO WATCH

  Else:
  Print ('Max Value changed by ' + inital_max_value - ws.max_row