Calc Direct Cell Font Effects
The ooodev.format.calc.direct.cell.font.FontEffects
class gives you the same options
as Calc’s Font Effects Dialog, but without the dialog as seen in Fig. 401.
Apply the font effects to a cell
Setup
from __future__ import annotations
import uno
from ooodev.calc import CalcDoc
from ooodev.loader import Lo
from ooodev.utils.color import CommonColor
from ooodev.format.inner.direct.write.char.font.font_effects import (
FontLine, FontUnderlineEnum
)
def main() -> int:
with Lo.Loader(connector=Lo.ConnectSocket()):
doc = CalcDoc.create_doc(visible=True)
sheet = doc.sheets[0]
Lo.delay(500)
doc.zoom_value(400)
cell = sheet["A1"]
cell.value = "Hello"
cell.style_font_effect(
color=CommonColor.RED,
underline=FontLine(
line=FontUnderlineEnum.SINGLE, color=CommonColor.BLUE
),
shadowed=True,
)
Lo.delay(1_000)
doc.close()
return 0
if __name__ == "__main__":
SystemExit(main())
Setting the font effects
# ... other code
cell = sheet["A1"]
cell.value = "Hello"
cell.style_font_effect(
color=CommonColor.RED,
underline=FontLine(line=FontUnderlineEnum.SINGLE, color=CommonColor.BLUE),
shadowed=True,
)
Running the above code will produce the following output in Fig. 347 and Fig. 348.
Getting the font effects from a cell
# ... other code
f_style = cell.style_font_effect_get()
assert f_effects.prop_color == CommonColor.RED
Apply the font effects to a range
Setup
from __future__ import annotations
import uno
from ooodev.calc import CalcDoc
from ooodev.loader import Lo
from ooodev.utils.color import CommonColor
from ooodev.format.inner.direct.write.char.font.font_effects import FontLine, FontUnderlineEnum
def main() -> int:
with Lo.Loader(connector=Lo.ConnectSocket()):
doc = CalcDoc.create_doc(visible=True)
sheet = doc.sheets[0]
Lo.delay(500)
doc.zoom_value(400)
rng = sheet.rng("A1:B1")
sheet.set_array(values=[["Hello", "World"]], range_obj=rng)
cell_rng = sheet.get_range(range_obj=rng)
cell_rng.style_font_effect(
color=CommonColor.RED,
underline=FontLine(line=FontUnderlineEnum.SINGLE, color=CommonColor.BLUE),
shadowed=True,
)
Lo.delay(1_000)
doc.close()
return 0
if __name__ == "__main__":
SystemExit(main())
Setting the font effects
# ... other code
cell_rng = sheet.get_range(range_obj=rng)
cell_rng.style_font_effect(
color=CommonColor.RED,
underline=FontLine(line=FontUnderlineEnum.SINGLE, color=CommonColor.BLUE),
shadowed=True,
)
Running the above code will produce the following output in Fig. 404 and Fig. 348.
Getting the font effects from a range
# ... other code
f_style = cell_rng.style_font_effect_get()
assert f_effects.prop_color == CommonColor.RED