Esempio n. 1
0
 def test_fill_rows(self, Worksheet, row, column, coordinate):
     ws = Worksheet(Workbook())
     ws['A1'] = 'first'
     ws['C9'] = 'last'
     assert ws.calculate_dimension() == 'A1:C9'
     rows = ws.iter_rows()
     first_row = next(islice(rows, row - 1, row))
     assert first_row[column].coordinate == coordinate
Esempio n. 2
0
def dummy_worksheet(Worksheet):
    """
    Creates a worksheet A1:H6 rows with values the same as cell coordinates
    """
    ws = Worksheet(DummyWorkbook())

    for row in ws.iter_rows(max_row=6, max_col=8):
        for cell in row:
            cell.value = cell.coordinate

    return ws
Esempio n. 3
0
    def test_iter_rows(self, Worksheet):
        ws = Worksheet(Workbook())
        expected = [
            ('A1', 'B1', 'C1'),
            ('A2', 'B2', 'C2'),
            ('A3', 'B3', 'C3'),
            ('A4', 'B4', 'C4'),
        ]

        rows = ws.iter_rows(min_row=1, min_col=1, max_row=4, max_col=3)
        for row, coord in zip(rows, expected):
            assert tuple(c.coordinate for c in row) == coord
Esempio n. 4
0
    def test_append_2d_list(self, Worksheet):

        ws = Worksheet(Workbook())

        ws.append(['This is A1', 'This is B1'])
        ws.append(['This is A2', 'This is B2'])

        vals = ws.iter_rows(min_row=1, min_col=1, max_row=2, max_col=2)
        expected = (
            ('This is A1', 'This is B1'),
            ('This is A2', 'This is B2'),
        )
        for e, v in zip(expected, ws.values):
            assert e == tuple(v)
Esempio n. 5
0
    def test_iter_rows_offset(self, Worksheet):
        ws = Worksheet(Workbook())
        rows = ws.iter_rows(min_row=1,
                            min_col=1,
                            max_row=4,
                            max_col=3,
                            row_offset=1,
                            column_offset=3)
        expected = [
            ('D2', 'E2', 'F2'),
            ('D3', 'E3', 'F3'),
            ('D4', 'E4', 'F4'),
            ('D5', 'E5', 'F5'),
        ]

        for row, coord in zip(rows, expected):
            assert tuple(c.coordinate for c in row) == coord