Calc Modify Page Background
Overview
The ooodev.format.calc.modify.page.area.Color
and ooodev.format.calc.modify.page.area.Img
classes sets the background options for the Calc page.
Setup
General function used to run these examples.
import uno
from ooodev.office.calc import Calc
from ooodev.gui import GUI
from ooodev.loader.lo import Lo
from ooodev.format.calc.modify.page.area import Color as PageStyleColor, CalcStylePageKind
from ooodev.format.calc.modify.page.area import Img as PageStyleImg, PresetImageKind
from ooodev.utils.color import StandardColor
def main() -> int:
with Lo.Loader(connector=Lo.ConnectSocket()):
doc = Calc.create_doc()
GUI.set_visible(True, doc)
Lo.delay(500)
Calc.zoom_value(doc, 100)
page_color_style = PageStyleColor(
color=StandardColor.GREEN_LIGHT2, style_name=CalcStylePageKind.DEFAULT
)
page_color_style.apply(doc)
style_obj = PageStyleColor.from_style(doc=doc, style_name=CalcStylePageKind.DEFAULT)
assert style_obj.prop_style_name == str(CalcStylePageKind.DEFAULT)
Lo.delay(1_000)
Lo.close_doc(doc)
return 0
if __name__ == "__main__":
SystemExit(main())
Background Color
Setting the Page Background Color
# .. other code
page_color_style = PageStyleColor(
color=StandardColor.GREEN_LIGHT2, style_name=CalcStylePageKind.DEFAULT
)
page_color_style.apply(doc)
Style results.
![Calc dialog Page Background style color modified](https://user-images.githubusercontent.com/4193389/236639347-f8ea096c-7f23-4d0c-a1f5-96d997c4727f.png)
Fig. 427 Calc dialog Page Background style color modified
Getting the background color from a style
# .. other code
style_obj = PageStyleColor.from_style(doc=doc, style_name=CalcStylePageKind.DEFAULT)
assert style_obj.prop_style_name == str(CalcStylePageKind.DEFAULT)
Background Image
Setting the Page Background Image
# .. other code
page_img_style = PageStyleImg.from_preset(
preset=PresetImageKind.COFFEE_BEANS, style_name=CalcStylePageKind.DEFAULT
)
page_img_style.apply(doc)
Style results.
![Calc dialog Page Background style image modified](https://user-images.githubusercontent.com/4193389/236640290-799efe37-4239-48e2-ab6a-8f6aed99f7c2.png)
Fig. 428 Calc dialog Page Background style image modified