Esempio n. 1
0
 def _merge_body_cell(self, end_column, end_row, start_column, start_row,
                      border, fill, font, al):
     self.ws_main.merge_cells(start_row=start_row,
                              start_column=start_column,
                              end_row=end_row,
                              end_column=end_column)
     # set merge cells style
     coordinate = coordinate_transfer(start_row, start_column) + ':' + coordinate_transfer(end_row, end_column)
     style_range(self.ws_main, coordinate, border, fill, font, al)
Esempio n. 2
0
    def _render_header(self):
        # render cell with style
        scale_x = self.header['scale'][0]
        scale_y = self.header['scale'][1]
        for i in range(scale_x):
            for j in range(scale_y):
                x = i + self.origin[0] + 1
                # y should add title
                y = j + self.origin[1]
                current_value = self.header['data'][i][j]
                checked_style = self._check_cube_style(i, j)
                current_cube = Cube(style=checked_style, value=current_value)
                self.core.write_cube_to_book(x, y, current_cube)

        # merge cell
        if self.header['merge'] is not None:
            bx = self.origin[0] + 1
            by = self.origin[1]
            for m in self.header['merge']:
                start_row = m['coordinate'][0] + bx
                start_column = m['coordinate'][1] + by
                end_row = m['coordinate'][2] + bx
                end_column = m['coordinate'][3] + by
                self.core.ws.merge_cells(start_row=start_row,
                                         start_column=start_column,
                                         end_row=end_row,
                                         end_column=end_column)
                # get style of cell need merged
                current_style = m['style']

                self._merge_body_cell(end_column, end_row, start_column,
                                      start_row,
                                      border_pattern[current_style.border],
                                      fill_pattern[current_style.fill],
                                      font_pattern[current_style.font],
                                      alignment_pattern[current_style.al])
                # set border
                coordinate = coordinate_transfer(
                    start_row, start_column) + ':' + coordinate_transfer(
                        end_row, end_column)
                style_range(self.core.ws,
                            coordinate,
                            border=border_pattern[current_style.border],
                            fill=fill_pattern[current_style.fill],
                            font=font_pattern[current_style.font],
                            alignment=alignment_pattern[current_style.al])
Esempio n. 3
0
    def _render_table_header(self):
        # render cell with style
        for i in range(self.header.x):
            for j in range(self.header.y):
                x = i + self.origin[0] - 1
                # y should add title
                y = j + self.origin[1] - 1
                current_value = self.header.matrix[i][j]
                checked_style = self._check_cube_style(i, j)
                current_cube = Cube(bg_color[4], value=current_value) if checked_style is None else Cube(
                    checked_style.fill, value=current_value)
                self.write_cube_to_book(x + 1, y + 1, current_cube)

        # merge cell
        if self.header.merge is not None:
            for m in self.header.merge:
                start_row = m['coordinate'][0] + self.origin[0]
                start_column = m['coordinate'][1] + self.origin[1]
                end_row = m['coordinate'][2] + self.origin[0]
                end_column = m['coordinate'][3] + self.origin[1]
                self.ws_main.merge_cells(start_row=start_row,
                                         start_column=start_column,
                                         end_row=end_row,
                                         end_column=end_column)
                # get style of cell need merged
                current_style = m['style']

                self._merge_body_cell(end_column, end_row, start_column, start_row,
                                      border_pattern[current_style.border], fill_pattern[current_style.fill],
                                      font_pattern[current_style.font], alignment_pattern[current_style.al])
                # set border
                coordinate = coordinate_transfer(start_row, start_column) + ':' + coordinate_transfer(end_row,
                                                                                                      end_column)
                style_range(self.ws_main, coordinate,
                            border=border_pattern[current_style.border],
                            fill=fill_pattern[current_style.fill],
                            font=font_pattern[current_style.font],
                            alignment=alignment_pattern[current_style.al])
Esempio n. 4
0
 def _add_table_border(self):
     coordinate = coordinate_transfer(self.origin[0] + 1, self.origin[1]) + ':' + \
                  coordinate_transfer(self.end_point[0], self.end_point[1])
     style_range(self.core.ws, coordinate, thick_border)