def test_image(pytestconfig): sheet = Sheet(root=Col( colspan=8, children=[ Row( rowspan=5, children=[ Cell("cell 1", bg_color="cyan", align="center"), Image( "assets/image.jpeg", colspan=4, offset=2, grow=True, align="center", border=1, options={ "x_scale": 0.2, "y_scale": 0.2 }, ), Cell("cell 2", bg_color="red", align="center"), ], ) ], )) if pytestconfig.getoption("update_snapshot"): sheet.write("tests/__snapshots__/image.xlsx") else: assert_match_snapshot(sheet, "image.xlsx")
def test_basic(pytestconfig): sheet = Sheet(root=Col( colspan=8, children=[ Row(children=[ Cell( "hello world", offset=2, grow=True, bg_color="yellow", align="center", border=1, ) ]) ], )) if pytestconfig.getoption("update_snapshot"): sheet.write("tests/__snapshots__/basic.xlsx") else: assert_match_snapshot(sheet, "basic.xlsx")
def test_complex_col(pytestconfig): sheet = Sheet( root=Row( # rowspan=8, children=[ Col( # offset=1, children=[ Cell( "cell 1", offset=2, grow=True, bg_color="yellow", align="center", border=1, ) ] ), Col( children=[ Cell("cell 2", bg_color="red", align="top", border=2), Cell( "cell 3", offset=1, grow=True, bg_color="green", align="bottom", ), Row( offset=1, children=[Cell("cell 4", rowspan=2), Cell("cell 5")], bg_color="red", ), ] ), Col( # rowspan=8, children=[ Cell("cell 6", rowspan=10, bg_color="cyan", align="center") ] ), ] ) ) if pytestconfig.getoption("update_snapshot"): # sheet.print() sheet.write("tests/__snapshots__/complex_col.xlsx") else: assert_match_snapshot(sheet, "complex_col.xlsx")