Пример #1
0
def _populate_table(table: Table,
                    cols: List[str],
                    rows: List[str],
                    values: List[List[str]],
                    first_cell: str = ' ') -> Table:
    """populate the cells of a pptx table from lists"""
    table.cell(0, 0).text = str(first_cell)
    for j, col in enumerate(cols):
        table.cell(0, j + 1).text = str(col)
    for i, row in enumerate(rows):
        table.cell(i + 1, 0).text = str(row)
    for j in range(len(cols)):
        for i in range(len(rows)):
            table.cell(i + 1, j + 1).text = str(values[i][j])
    return table
Пример #2
0
    def generate_content(self, pptx_table: Table):
        for col_nr, pptx_col in enumerate(pptx_table.columns):
            pptx_col.width = self._column_widths[col_nr]

        for row_index, row in enumerate(self._rows):
            pptx_row: _Row = pptx_table.rows[row_index]
            pptx_row.height = row.height
            for col_index, row_cell in enumerate(row._row_cells):
                cell = pptx_table.cell(row_index, col_index)
                row_cell.apply_styles(cell)
Пример #3
0
    def it_provides_access_to_its_cells(self, tbl_, tc_, _Cell_, cell_):
        row_idx, col_idx = 4, 2
        tbl_.tc.return_value = tc_
        _Cell_.return_value = cell_
        table = Table(tbl_, None)

        cell = table.cell(row_idx, col_idx)

        tbl_.tc.assert_called_once_with(row_idx, col_idx)
        _Cell_.assert_called_once_with(tc_, table)
        assert cell is cell_
Пример #4
0
    def it_provides_access_to_its_cells(self, tbl_, tc_, _Cell_, cell_):
        row_idx, col_idx = 4, 2
        tbl_.tc.return_value = tc_
        _Cell_.return_value = cell_
        table = Table(tbl_, None)

        cell = table.cell(row_idx, col_idx)

        tbl_.tc.assert_called_once_with(row_idx, col_idx)
        _Cell_.assert_called_once_with(tc_, table)
        assert cell is cell_