Beispiel #1
0
    def test_document_to_workbook(self):
        doc = table_one + table_two
        wb = document_to_workbook(doc)
        self.assertEqual(wb.sheetnames, ['simple table', 'second table'])

        sheet = wb['second table']  # Get sheet with the title `span table`
        self.assertEqual(sheet['B1'].value, 'B1 cell')

        # Add another sheet to the existing workbook
        wb = document_to_workbook(table_three, wb=wb)
        self.assertEqual(wb.sheetnames, ['simple table', 'second table', 'Another simple table'])
    def test_document_to_workbook(self):
        doc = table_one + table_two
        wb = document_to_workbook(doc)
        self.assertEqual(wb.sheetnames, ['simple table', 'second table'])

        sheet = wb['second table']  # Get sheet with the title `span table`
        self.assertEqual(sheet['B1'].value, 'B1 cell')

        # Add another sheet to the existing workbook
        wb = document_to_workbook(table_three, wb=wb)
        self.assertEqual(wb.sheetnames, ['simple table', 'second table', 'Another simple table'])
Beispiel #3
0
    def test_element_whitespace(self):
        doc = table_whitespace
        wb = document_to_workbook(doc)
        sheet = wb['whitespace table']

        self.assertEqual(sheet['A1'].value,
                         'a  bc\nd  ef\ng  hi\nj  k\nl  m\nn  o\np')
Beispiel #4
0
    def test_spans(self):
        doc = table_span
        wb = document_to_workbook(doc)
        sheet = wb['span table']  # Get sheet with the title `span table`

        self.assertIn("A1:C1", [x.coord for x in sheet.merged_cells.ranges])
        self.assertIn("A2:A5", [x.coord for x in sheet.merged_cells.ranges])
def html_table_to_xlsx(s):
    if s.strip() == '':
        return ''
    workbook = tablepyxl.document_to_workbook(s)
    output = io.BytesIO()
    workbook.save(output)
    return base64.encodebytes(output.getvalue()).decode('utf-8')
    def test_spans(self):
        doc = table_span
        wb = document_to_workbook(doc)
        sheet = wb['span table']  # Get sheet with the title `span table`

        self.assertIn("A1:C1", [x.coord for x in sheet.merged_cells.ranges])
        self.assertIn("A2:A5", [x.coord for x in sheet.merged_cells.ranges])
Beispiel #7
0
 def test_width(self):
     doc = table_widths
     wb = document_to_workbook(doc)
     sheet = wb['width table']  # Get sheet with the title `width table`
     self.assertEqual(sheet.column_dimensions['A'].width, 6)
Beispiel #8
0
 def test_comments(self):
     wb = document_to_workbook(table_comment)
     sheet = wb['comment table']
     self.assertNotIn('this is a html comment', sheet['A1'].value)
     self.assertEqual(sheet['B1'].value, 'this is not a html comment')
    def test_element_whitespace(self):
        doc = table_whitespace
        wb = document_to_workbook(doc)
        sheet = wb['whitespace table']

        self.assertEqual(sheet['A1'].value, 'a  bc\nd  ef\ng  hi\nj  k\nl  m\nn  o\np')
Beispiel #10
0
 def test_width(self):
     doc = table_widths
     wb = document_to_workbook(doc)
     sheet = wb['width table']  # Get sheet with the title `width table`
     self.assertEqual(sheet.column_dimensions['A'].width, 6)
Beispiel #11
0
 def test_comments(self):
     wb = document_to_workbook(table_comment)
     sheet = wb['comment table']
     self.assertNotIn('this is a html comment', sheet['A1'].value)
     self.assertEqual(sheet['B1'].value, 'this is not a html comment')