openpyxl模块-------------------------------函数公式应用

求和代码:
#!/usr/bin/env python

from openpyxl import Workbook

book = Workbook()
sheet = book.active

rows = (
(34, 26),
(88, 36),
(24, 29),
(15, 22),
(56, 13),
(76, 18)
)

for row in rows:
sheet.append(row)

cell = sheet.cell(row=7, column=2)
cell.value = "=SUM(A1:B6)"
cell.font = cell.font.copy(bold=True)

book.save('formulas.xlsx')
实现效果如下:

 

posted @ 2023-07-25 10:49  往事已成昨天  阅读(13)  评论(0编辑  收藏  举报