Esempio n. 1
0
    lines = 50
    cols = 20

    for line in range(lines):
        row = Row()
        for column in range(cols):
            row.set_value(column, "%s%s" % (chr(65 + column), line + 1))
        table.append(row)

    print("Size of Table :", table.size)

    table2 = Table("Symetry")

    # building the symetric table using classical method :
    for x in range(cols):
        values = table.get_column_values(x)
        table2.set_row_values(x, values)
    body.append(table2)

    print("Size of symetric table 2 :", table2.size)

    # a more simple solution with the table.transpose() method :
    table3 = table.clone
    table3.transpose()
    table3.name = "Transpose"
    body.append(table3)

    print("Size of symetric table 3 :", table3.size)

    if not os.path.exists("test_output"):
        os.mkdir("test_output")
Esempio n. 2
0
        row_number += 1
        table.set_row(row_number, row)

    cols = table.width
    column = cols - 1

    # add merged empty row
    row = Row()
    row_number += 1
    table.set_row(row_number, row)
    table.set_span((0, row_number, 3, row_number))

    # make total
    row = Row()
    row.set_value(column - 1, "Total:")
    total = sum(table.get_column_values(column)[1:-1])
    cell = Cell()
    cell.set_value(total,
                   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)

    row = Row()
    row.set_value(column - 1, "Total with tax:")