コード例 #1
0
ファイル: test_simple.py プロジェクト: nevergiveupme/learngit
 def test_create_simple_xls(self):
     wb, _ = self.create_simple_xls()
     wb.save(in_tst_output_dir('simple.xls'))
     self.assertTrue(
         filecmp.cmp(in_tst_dir('simple.xls'),
                     in_tst_output_dir('simple.xls'),
                     shallow=False))
コード例 #2
0
ファイル: test_mini.py プロジェクト: Bakouru/xlwt
    def test_create_mini_xls(self):
        book = xlwt.Workbook()
        sheet = book.add_sheet('xlwt was here')
        book.save(in_tst_output_dir('mini.xls'))

        self.assertTrue(filecmp.cmp(in_tst_dir('mini.xls'),
                                    in_tst_output_dir('mini.xls'),
                                    shallow=False))
コード例 #3
0
ファイル: test_mini.py プロジェクト: zhangziliang04/xlwt
    def test_create_mini_xls(self):
        book = xlwt.Workbook()
        sheet = book.add_sheet('xlwt was here')
        book.save(in_tst_output_dir('mini.xls'))

        self.assertTrue(filecmp.cmp(in_tst_dir('mini.xls'),
                                    in_tst_output_dir('mini.xls'),
                                    shallow=False))
コード例 #4
0
ファイル: test_bitmaps.py プロジェクト: ranade1/hue
 def test_create_bitmap_from_file(self):
     book = xlwt.Workbook()
     sheet = book.add_sheet('bitmap test')
     
     sheet.insert_bitmap("tests/python.bmp", 1, 1)
     
     book.save(in_tst_output_dir('bitmaps.xls'))
     
     self.assertTrue(filecmp.cmp(in_tst_dir('bitmaps.xls'),
                                 in_tst_output_dir('bitmaps.xls'),
                                 shallow=False))
コード例 #5
0
ファイル: test_bitmaps.py プロジェクト: Bakouru/xlwt
 def test_create_bitmap_from_file(self):
     book = xlwt.Workbook()
     sheet = book.add_sheet('bitmap test')
     
     sheet.insert_bitmap("tests/python.bmp", 1, 1)
     
     book.save(in_tst_output_dir('bitmaps.xls'))
     
     self.assertTrue(filecmp.cmp(in_tst_dir('bitmaps.xls'),
                                 in_tst_output_dir('bitmaps.xls'),
                                 shallow=False))
コード例 #6
0
ファイル: test_bitmaps.py プロジェクト: Bakouru/xlwt
 def test_create_bitmap_from_memory(self):
     book = xlwt.Workbook()
     sheet = book.add_sheet('bitmap test')
     
     with open ("tests/python.bmp", "rb") as bmpfile:
         bmpdata = bmpfile.read()
         sheet.insert_bitmap_data(bmpdata, 1, 1)
     
     book.save(in_tst_output_dir('bitmaps.xls'))
     
     self.assertTrue(filecmp.cmp(in_tst_dir('bitmaps.xls'),
                                 in_tst_output_dir('bitmaps.xls'),
                                 shallow=False))
コード例 #7
0
ファイル: test_bitmaps.py プロジェクト: ranade1/hue
 def test_create_bitmap_from_memory(self):
     book = xlwt.Workbook()
     sheet = book.add_sheet('bitmap test')
     
     with open ("tests/python.bmp", "rb") as bmpfile:
         bmpdata = bmpfile.read()
         sheet.insert_bitmap_data(bmpdata, 1, 1)
     
     book.save(in_tst_output_dir('bitmaps.xls'))
     
     self.assertTrue(filecmp.cmp(in_tst_dir('bitmaps.xls'),
                                 in_tst_output_dir('bitmaps.xls'),
                                 shallow=False))
コード例 #8
0
ファイル: test_simple.py プロジェクト: nevergiveupme/learngit
 def test_create_less_simple_xls(self):
     wb, ws = self.create_simple_xls()
     more_content = [[
         u'A{0}'.format(i),
         u'Zażółć gęślą jaźń {0} {1}'.format(i, LOREM_IPSUM),
     ] for idx, i in enumerate(range(1000, 1050))]
     for r_idx, content_row in enumerate(more_content, 3):
         for c_idx, cell in enumerate(content_row):
             ws.write(r_idx, c_idx, cell)
     wb.save(in_tst_output_dir('less_simple.xls'))
     self.assertTrue(
         filecmp.cmp(in_tst_dir('less_simple.xls'),
                     in_tst_output_dir('less_simple.xls'),
                     shallow=False))
コード例 #9
0
ファイル: test_simple.py プロジェクト: thektulu/xlwt
    def create_simple_xls(self, filename='simple.xls', more_content=None):
        font0 = xlwt.Font()
        font0.name = 'Times New Roman'
        font0.colour_index = 2
        font0.bold = True

        style0 = xlwt.XFStyle()
        style0.font = font0

        style1 = xlwt.XFStyle()
        style1.num_format_str = 'D-MMM-YY'

        wb = xlwt.Workbook()
        ws = wb.add_sheet('A Test Sheet')

        ws.write(0, 0, 'Test', style0)
        ws.write(1, 0, datetime(2010, 12, 5), style1)
        ws.write(2, 0, 1)
        ws.write(2, 1, 1)
        ws.write(2, 2, xlwt.Formula("A3+B3"))
        if more_content is not None:
            for r_idx, content_row in enumerate(more_content, 3):
                for c_idx, cell in enumerate(content_row):
                    ws.write(r_idx, c_idx, cell)

        wb.save(in_tst_output_dir(filename))
コード例 #10
0
ファイル: test_simple.py プロジェクト: MagesInstitute/xlwt
    def create_simple_xls(self, filename='simple.xls', more_content=None):
        font0 = xlwt.Font()
        font0.name = 'Times New Roman'
        font0.colour_index = 2
        font0.bold = True

        style0 = xlwt.XFStyle()
        style0.font = font0

        style1 = xlwt.XFStyle()
        style1.num_format_str = 'D-MMM-YY'

        wb = xlwt.Workbook()
        ws = wb.add_sheet('A Test Sheet')

        ws.write(0, 0, 'Test', style0)
        ws.write(1, 0, datetime(2010, 12, 5), style1)
        ws.write(2, 0, 1)
        ws.write(2, 1, 1)
        ws.write(2, 2, xlwt.Formula("A3+B3"))
        if more_content is not None:
            for r_idx, content_row in enumerate(more_content, 3):
                for c_idx, cell in enumerate(content_row):
                    ws.write(r_idx, c_idx, cell)

        wb.save(in_tst_output_dir(filename))
コード例 #11
0
ファイル: test_simple.py プロジェクト: taojy123/BySM
 def test_create_less_simple_xls(self):
     wb, ws = self.create_simple_xls()
     more_content=[
         [
             u'A{0}'.format(i),
             u'Zażółć gęślą jaźń {0} {1}'.format(i, LOREM_IPSUM),
         ]
         for idx, i in enumerate(range(1000, 1050))
     ]
     for r_idx, content_row in enumerate(more_content, 3):
         for c_idx, cell in enumerate(content_row):
             ws.write(r_idx, c_idx, cell)
     wb.save(in_tst_output_dir('less_simple.xls'))
     self.assertTrue(filecmp.cmp(in_tst_dir('less_simple.xls'),
                                 in_tst_output_dir('less_simple.xls'),
                                 shallow=False))
コード例 #12
0
    def create_nan_xls(self, filename='nan.xls'):
        wb = xlwt.Workbook()
        ws = wb.add_sheet('A Test Sheet')

        ws.write(0, 0, 1)
        ws.write(0, 1, float('nan'))
        wb.save(in_tst_output_dir(filename))
コード例 #13
0
ファイル: test_simple.py プロジェクト: thektulu/xlwt
 def test_create_less_simple_xls(self):
     self.create_simple_xls(filename='less_simple.xls',
                            more_content=[[
                                u'A{0}'.format(i),
                                u'Zażółć gęślą jaźń {0} {1}'.format(
                                    i, LOREM_IPSUM),
                            ] for idx, i in enumerate(range(1000, 1050))])
     self.assertTrue(
         filecmp.cmp(in_tst_dir('less_simple.xls'),
                     in_tst_output_dir('less_simple.xls'),
                     shallow=False))
コード例 #14
0
    def test_worksheet(self):
        book = xlwt.Workbook()
        first_page = "Page 1"

        sheet = book.add_sheet(first_page)
        assert sheet.get_name() == first_page

        sheet.set_name('Page 2')
        assert sheet.get_name() == 'Page 2'

        sheet.set_header_str(first_page)
        assert sheet.get_header_str() == first_page

        sheet.set_footer_str(first_page)
        assert sheet.get_footer_str() == first_page

        sheet.set_left_margin(0.45)
        assert sheet.get_left_margin() == 0.45

        sheet.set_right_margin(0.45)
        assert sheet.get_right_margin() == 0.45

        sheet.set_top_margin(0.45)
        assert sheet.get_top_margin() == 0.45

        sheet.set_bottom_margin(0.45)
        assert sheet.get_bottom_margin() == 0.45

        sheet.set_header_margin(0.45)
        assert sheet.get_header_margin() == 0.45

        sheet.set_footer_margin(0.45)
        assert sheet.get_footer_margin() == 0.45

        sheet.set_portrait(False)
        assert sheet.get_portrait() is False

        sheet.set_fit_num_pages(2)
        assert sheet.get_fit_num_pages() == 2

        sheet.set_fit_num_pages(1)
        assert sheet.get_fit_num_pages() == 1

        sheet.set_fit_width_to_pages(1)
        assert sheet.get_fit_width_to_pages() == 1

        sheet.set_fit_height_to_pages(0)
        assert sheet.get_fit_height_to_pages() == 0

        book.save(in_tst_output_dir('worksheet.xls'))
コード例 #15
0
ファイル: test_simple.py プロジェクト: MagesInstitute/xlwt
 def test_create_less_simple_xls(self):
     self.create_simple_xls(
         filename='less_simple.xls',
         more_content=[
             [
                 u'A{0}'.format(i),
                 u'Zażółć gęślą jaźń {0} {1}'.format(i, LOREM_IPSUM),
             ]
             for idx, i in enumerate(range(1000, 1050))
         ]
     )
     self.assertTrue(filecmp.cmp(in_tst_dir('less_simple.xls'),
                                 in_tst_output_dir('less_simple.xls'),
                                 shallow=False))
コード例 #16
0
    def create_simple_xls(self):
        font0 = xlwt.Font()
        font0.name = 'Times New Roman'
        font0.colour_index = 2
        font0.bold = True

        style0 = xlwt.XFStyle()
        style0.font = font0

        style1 = xlwt.XFStyle()
        style1.num_format_str = 'D-MMM-YY'

        wb = xlwt.Workbook()
        ws = wb.add_sheet('A Test Sheet')

        ws.write(0, 0, 'Test', style0)
        ws.write(1, 0, datetime(2010, 12, 5), style1)
        ws.write(2, 0, 1)
        ws.write(2, 1, 1)
        ws.write(2, 2, xlwt.Formula("A3+B3"))

        wb.save(in_tst_output_dir('simple.xls'))
コード例 #17
0
ファイル: test_simple.py プロジェクト: wangwp0822/pythontool
    def create_simple_xls(self):
        font0 = xlwt.Font()
        font0.name = 'Times New Roman'
        font0.colour_index = 2
        font0.bold = True

        style0 = xlwt.XFStyle()
        style0.font = font0

        style1 = xlwt.XFStyle()
        style1.num_format_str = 'D-MMM-YY'

        wb = xlwt.Workbook()
        ws = wb.add_sheet('A Test Sheet')

        ws.write(0, 0, 'Test', style0)
        ws.write(1, 0, datetime(2010, 12, 5), style1)
        ws.write(2, 0, 1)
        ws.write(2, 1, 1)
        ws.write(2, 2, xlwt.Formula("A3+B3"))

        wb.save(in_tst_output_dir('simple.xls'))
コード例 #18
0
 def test_example_xls(self):
     self.create_example_xls(in_tst_output_dir(EXAMPLE_XLS))
     self.assertTrue(filecmp.cmp(in_tst_dir(EXAMPLE_XLS),
                                 in_tst_output_dir(EXAMPLE_XLS),
                                 shallow=False))
コード例 #19
0
 def test_example_xls(self):
     create_example_xls(in_tst_output_dir(EXAMPLE_XLS))
     self.assertTrue(filecmp.cmp(in_tst_dir(EXAMPLE_XLS),
                                 in_tst_output_dir(EXAMPLE_XLS),
                                 shallow=False))
コード例 #20
0
 def test_create_simple_xls(self):
     self.create_simple_xls()
     self.assertTrue(filecmp.cmp(in_tst_dir('simple.xls'),
                                 in_tst_output_dir('simple.xls'),
                                 shallow=False))
コード例 #21
0
 def test_create_nan_xls(self):
     self.create_nan_xls()
     self.assertTrue(filecmp.cmp(in_tst_dir('nan.xls'),
                                 in_tst_output_dir('nan.xls'),
                                 shallow=False))
コード例 #22
0
ファイル: test_simple.py プロジェクト: taojy123/BySM
 def test_font_compression(self):
     wb, ws = self.create_simple_xls(style_compression = 2)
     wb.save(in_tst_output_dir('simple.xls'), )
コード例 #23
0
ファイル: test_simple.py プロジェクト: nevergiveupme/learngit
 def test_font_compression(self):
     wb, ws = self.create_simple_xls(style_compression=2)
     wb.save(in_tst_output_dir('simple.xls'), )