效果:
代码:
import openpyxl
from openpyxl.styles import Font
wb = openpyxl.load_workbook("/Users/table.xlsx")
ws = wb.active
font1 = Font(name="微软雅黑", size=20, bold=True, italic=True, color="FF0000")
# name:字体类型,size:字体大小,bold:是否加粗,italic:是否斜体,color:字体颜色
ws["A2"].font = font1
# 应用字体样式
wb.save("/Users/table.xlsx")