table = Table('use_case3') for y in range(0, 256, 8): row = Row() for x in range(0, 256, 32): cell_value = (x, y, (x + y) % 256) border_rl = make_table_cell_border_string(thick='0.20cm', color='white') border_bt = make_table_cell_border_string( thick='0.80cm', color='white', ) style = create_table_cell_style( color='grey', background_color=cell_value, border_right=border_rl, border_left=border_rl, border_bottom=border_bt, border_top=border_bt, ) name = document.insert_style(style=style, automatic=True) cell = Cell(value=rgb2hex(cell_value), style=name) row.append_cell(cell) table.append_row(row) row_style = Style('table-row', height='1.80cm') name_style_row = document.insert_style(style=row_style, automatic=True) for row in table.get_rows(): row.style = name_style_row table.set_row(row.y, row) col_style = Style('table-column', width='3.6cm')
text="%.2f €" % total, currency="EUR", cell_type="float") row.set_cell(column, cell) row_number += 1 table.set_row(row_number, row) # let merge some cells table.set_span((column - 3, row_number, column - 1, row_number), merge=True) # Let's add some style on first row border = make_table_cell_border_string(thick='0.03cm', color='black') cell_style = create_table_cell_style( color='black', background_color=(210, 210, 210), border_right=border, border_left=border, border_bottom=border, border_top=border, ) style_name = commercial.insert_style(style=cell_style, automatic=True) row = table.get_row(0) #for cell in row.get_cells(): #possible, but .traverse() is better for cell in row.traverse(): cell.style = style_name row.set_cell(x=cell.x, cell=cell) table.set_row(row.y, row) if not os.path.exists('test_output'): os.mkdir('test_output')