コード例 #1
0
    def test_from_openpyxl_style(self):
        styler_obj = Styler(bg_color=utils.colors.yellow, bold=True, font=utils.fonts.david, font_size=16,
                            font_color=utils.colors.blue, number_format=utils.number_formats.date, protection=True,
                            underline=utils.underline.double, border_type=utils.borders.double,
                            horizontal_alignment=utils.horizontal_alignments.center,
                            vertical_alignment=utils.vertical_alignments.bottom, wrap_text=False, shrink_to_fit=True,
                            fill_pattern_type=utils.fill_pattern_types.gray0625, indent=1)

        self.assertEqual(styler_obj, Styler.from_openpyxl_style(styler_obj.to_openpyxl_style(), []))
コード例 #2
0
    def test_read_excel_with_style_openpyxl_objects(self):
        self.export_and_get_default_sheet(save=True)
        sf_from_excel = StyleFrame.read_excel(TEST_FILENAME, read_style=True, use_openpyxl_styles=True)
        # making sure content is the same
        self.assertTrue(all(list(self.sf[col]) == list(sf_from_excel[col]) for col in self.sf.columns))

        rows_in_excel = sf_from_excel.data_df.itertuples()
        rows_in_self = self.sf.data_df.itertuples()

        # making sure styles are the same
        self.assertTrue(all(self_cell.style == Styler.from_openpyxl_style(excel_cell.style, [])
                            for row_in_excel, row_in_self in zip(rows_in_excel, rows_in_self)
                            for excel_cell, self_cell in zip(row_in_excel[1:], row_in_self[1:])))