Example #1
0
    def test_to_excel_styleconverter(self):
        _skip_if_no_openpyxl()

        import openpyxl

        hstyle = {
            "font": {
                "bold": True
            },
            "borders": {
                "top": "thin",
                "right": "thin",
                "bottom": "thin",
                "left": "thin"
            },
            "alignment": {
                "horizontal": "center",
                "vertical": "top"
            }
        }

        xlsx_style = _OpenpyxlWriter._convert_to_style(hstyle)
        self.assertTrue(xlsx_style.font.bold)
        self.assertEquals(openpyxl.style.Border.BORDER_THIN,
                          xlsx_style.borders.top.border_style)
        self.assertEquals(openpyxl.style.Border.BORDER_THIN,
                          xlsx_style.borders.right.border_style)
        self.assertEquals(openpyxl.style.Border.BORDER_THIN,
                          xlsx_style.borders.bottom.border_style)
        self.assertEquals(openpyxl.style.Border.BORDER_THIN,
                          xlsx_style.borders.left.border_style)
        self.assertEquals(openpyxl.style.Alignment.HORIZONTAL_CENTER,
                          xlsx_style.alignment.horizontal)
        self.assertEquals(openpyxl.style.Alignment.VERTICAL_TOP,
                          xlsx_style.alignment.vertical)
Example #2
0
    def test_to_excel_styleconverter(self):
        _skip_if_no_openpyxl()
        if not openpyxl_compat.is_compat():
            raise nose.SkipTest('incompatiable openpyxl version')

        import openpyxl

        hstyle = {"font": {"bold": True},
                  "borders": {"top": "thin",
                              "right": "thin",
                              "bottom": "thin",
                              "left": "thin"},
                  "alignment": {"horizontal": "center", "vertical": "top"}}

        xlsx_style = _OpenpyxlWriter._convert_to_style(hstyle)
        self.assertTrue(xlsx_style.font.bold)
        self.assertEqual(openpyxl.style.Border.BORDER_THIN,
                         xlsx_style.borders.top.border_style)
        self.assertEqual(openpyxl.style.Border.BORDER_THIN,
                         xlsx_style.borders.right.border_style)
        self.assertEqual(openpyxl.style.Border.BORDER_THIN,
                         xlsx_style.borders.bottom.border_style)
        self.assertEqual(openpyxl.style.Border.BORDER_THIN,
                         xlsx_style.borders.left.border_style)
        self.assertEqual(openpyxl.style.Alignment.HORIZONTAL_CENTER,
                         xlsx_style.alignment.horizontal)
        self.assertEqual(openpyxl.style.Alignment.VERTICAL_TOP,
                         xlsx_style.alignment.vertical)
Example #3
0
    def test_to_excel_styleconverter(self):
        _skip_if_no_openpyxl()

        import openpyxl

        hstyle = {"font": {"bold": True},
                  "borders": {"top": "thin",
                              "right": "thin",
                              "bottom": "thin",
                              "left": "thin"},
                  "alignment": {"horizontal": "center"}}

        xlsx_style = _OpenpyxlWriter._convert_to_style(hstyle)
        self.assertTrue(xlsx_style.font.bold)
        self.assertEquals(openpyxl.style.Border.BORDER_THIN,
                          xlsx_style.borders.top.border_style)
        self.assertEquals(openpyxl.style.Border.BORDER_THIN,
                          xlsx_style.borders.right.border_style)
        self.assertEquals(openpyxl.style.Border.BORDER_THIN,
                          xlsx_style.borders.bottom.border_style)
        self.assertEquals(openpyxl.style.Border.BORDER_THIN,
                          xlsx_style.borders.left.border_style)
        self.assertEquals(openpyxl.style.Alignment.HORIZONTAL_CENTER,
                          xlsx_style.alignment.horizontal)