Font

Font(实现)

字体对象可以作为 range 或 shape 对象的属性访问。

  • mysheet['A1'].font

  • mysheet.shapes[0].font

新增于版本0.23.0。

属性 api

返回所使用引擎的原生对象 (pywin32appscriptobj) 使用的引擎的成员。

新增于版本0.23.0。

属性 粗体

返回或设置粗体属性(布尔值)。

>>> sheet['A1'].font.bold = True
>>> sheet['A1'].font.bold
True

新增于版本0.23.0。

属性 颜色

返回或设置颜色属性(元组)。

>>> sheet['A1'].font.color = (255, 0, 0)  # or '#ff0000'
>>> sheet['A1'].font.color
(255, 0, 0)

新增于版本0.23.0。

属性 斜体

返回或设置斜体属性(布尔值)。

>>> sheet['A1'].font.italic = True
>>> sheet['A1'].font.italic
True

新增于版本0.23.0。

属性 名称

返回或设置字体名称(字符串)。

>>> sheet['A1'].font.name = 'Calibri'
>>> sheet['A1'].font.name
Calibri

新增于版本0.23.0。

属性 大小

返回或设置大小(浮点数)。

>>> sheet['A1'].font.size = 13
>>> sheet['A1'].font.size
13

新增于版本0.23.0。