How to change font size in Python OpenPyXL

随声附和 提交于 2019-12-13 22:13:20

问题


How do I change the font size of a cell? I am using OpenPyXL.

It will not let me send this question without typing the above with perfect grammar and spelling, so the last few words people should know what I mean.


回答1:


This works for me:

from openpyxl.styles import Font
fontStyle = Font(size = "10")
ws.cell(row = 1, column = 1, value = 'Test Text').font = fontStyle

I'm using openpyxl version: 2.3.2




回答2:


Openpyxl styling can achieve this for you!

cell.style.font.size = "font size goes here as integer"


来源:https://stackoverflow.com/questions/49156578/how-to-change-font-size-in-python-openpyxl

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!