在设置表头样式的for循环中,添加以下代码即可:

header_fill = PatternFill('solid', fgColor='C5E0B4') # 紫色 for col, header in enumerate(headers, start=1): cell = ws.cell(row=1, column=col, value=header) cell.font = header_font cell.fill = header_fill # 设置背景色 cell.alignment = header_alignment

将下面python3代码Excel中M列表头背景色设置为紫色字体加粗import osimport reimport subprocessimport openpyxlimport mathfrom openpyxlstyles import Font PatternFill Alignment# 视频格式supported_formats = mp4 avi mkv w

原文地址: http://www.cveoy.top/t/topic/beKA 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录