字体
Font(name=None, sz=None, b=None, i=None, charset=None, u=None, strike=None, color=None, scheme=None, family=None, size=None, bold=None, italic=None, strikethrough=None, underline=None, vertAlign=None, outline=None, shadow=None, condense=None, extend=None)
from openpyxl.styles import Font, Alignment, Border, Side, PatternFill
cell.font = Font(name='Times New Roman', bold=True, color='FF0000')
填充
PatternFill(patternType=None, fgColor=Color(), bgColor=Color(), fill_type=None, start_color=None, end_color=None)
yellow = 'FFFF00'
cell.fill = PatternFill(start_color=yellow, end_color=yellow, fill_type='solid')
对齐
Alignment(horizontal=None, vertical=None, textRotation=0, wrapText=None, shrinkToFit=None, indent=0, relativeIndent=0, justifyLastLine=None, readingOrder=0, text_rotation=None, wrap_text=None, shrink_to_fit=None, mergeCell=None)
cell.alignment = Alignment(horizontal='center', vertical='center')
# 自动换行
cell.alignment = Alignment(horizontal='left',vertical='center', wrap_text=True)
边框
Border(left=Side(), right=Side(), top=Side(), bottom=Side(), diagonal=Side(), diagonal_direction=None, vertical=None, horizontal=None, diagonalUp=False, diagonalDown=False, outline=True, start=None, end=None)
thin = Side(style='thin', color='CCCCCC')
cell.border = Border(top=thin, left=thin, right=thin, bottom=thin)