因为要用for 语句,所以应该用cell语句最好。毕竟for 语句不能把Z+1变成AA。
代码如下:
import openpyxl as xl
from openpyxl.formula.translate import Translator as tr
excel=xl.load_workbook('d:/MM.xlsx')
sheets=excel.sheetnames
sheet=excel[sheets[0]]
print(sheet['n9'])
sheet['n10'] = tr(sheet['n9'].value, origin="n9").translate_formula("n10")
excel.save('d:/m2.xlsx')