Calc Modify Page Sheet

Overview

The ooodev.format.calc.modify.page.sheet.Order and ooodev.format.calc.modify.page.sheet.Printing classes sets the sheet order and print options for the Calc page.

The Scale section is set using the ooodev.format.calc.modify.page.sheet.ScaleReduceEnlarge, ooodev.format.calc.modify.page.sheet.ScaleNumOfPages and ooodev.format.calc.modify.page.sheet.ScalePagesWidthHeight classes.

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.sheet import Order, Printing
from ooodev.format.calc.modify.page.sheet import CalcStylePageKind

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)

        style = Order(top_btm=False, first_pg=0, style_name=CalcStylePageKind.DEFAULT)
        style.apply(doc)

        style_obj = Order.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())

Page Order

The Order class sets the page order of the page sheet style.

Setting the Page Order

# .. other code
style = Order(top_btm=False, first_pg=0, style_name=CalcStylePageKind.DEFAULT)
style.apply(doc)

Style results.

Calc dialog Page Style Sheet Order modified

Fig. 440 Calc dialog Page Style Sheet Order modified

Getting the page order from a style

# .. other code
style_obj = Order.from_style(doc=doc, style_name=CalcStylePageKind.DEFAULT)
assert style_obj.prop_style_name == str(CalcStylePageKind.DEFAULT)

Scale Options

Reduce/Enlarge

The ScaleReduceEnlarge class sets the scale reduce/enlarge settings of the page sheet style.

Setting the Page Scale Reduce/Enlarge

from ooodev.format.calc.modify.page.sheet import ScaleReduceEnlarge, CalcStylePageKind

# .. other code
style = ScaleReduceEnlarge(factor=200, style_name=CalcStylePageKind.DEFAULT)
style.apply(doc)

Style results.

Calc dialog Page Style Sheet Scale style image modified

Fig. 442 Calc dialog Page Style Sheet Scale style image modified

Getting the page scale reduce/enlarge from a style

# .. other code
style_obj = ScaleReduceEnlarge.from_style(doc=doc, style_name=CalcStylePageKind.DEFAULT)
assert style_obj.prop_style_name == str(CalcStylePageKind.DEFAULT)

Width/Height

The ScalePagesWidthHeight class sets the scale width/height settings of the page sheet style.

Setting the Page Scale Width/Height

from ooodev.format.calc.modify.page.sheet import ScalePagesWidthHeight, CalcStylePageKind

# .. other code
style = ScalePagesWidthHeight(width=2, height=3, style_name=CalcStylePageKind.DEFAULT)
style.apply(doc)

Style results.

Calc dialog Page Style Sheet Scale style image modified

Fig. 443 Calc dialog Page Style Sheet Scale style image modified

Getting the page scale width/height from a style

# .. other code
style_obj = ScalePagesWidthHeight.from_style(doc=doc, style_name=CalcStylePageKind.DEFAULT)
assert style_obj.prop_style_name == str(CalcStylePageKind.DEFAULT)

Number of Pages

The ScaleNumOfPages class sets the scale number of pages settings of the page sheet style.

Setting the Page by Number of Pages

from ooodev.format.calc.modify.page.sheet import ScaleNumOfPages, CalcStylePageKind

# .. other code
style = ScaleNumOfPages(pages=3, style_name=CalcStylePageKind.DEFAULT)
style.apply(doc)

Style results.

Calc dialog Page Style Sheet Scale style image modified

Fig. 444 Calc dialog Page Style Sheet Scale style image modified

Getting the Page Sheet Scale Number of pages from a style

# .. other code
style_obj = ScaleNumOfPages.from_style(doc=doc, style_name=CalcStylePageKind.DEFAULT)
assert style_obj.prop_style_name == str(CalcStylePageKind.DEFAULT)