Example #1
0
    def test_insert_table_at_cell(self):
        wb = Workbook()
        ws = wb.active
        cell = ws['B2']

        table = get_Tables(table_one)
        insert_table_at_cell(table[0], cell)

        self.assertEqual(ws['B2'].value, 'A cell')
Example #2
0
    def test_insert_table_at_cell(self):
        wb = Workbook()
        ws = wb.active
        cell = ws['B2']

        table = get_Tables(table_one)
        insert_table_at_cell(table[0], cell)

        self.assertEqual(ws['B2'].value, 'A cell')
Example #3
0
    def test_table_to_sheet(self):
        wb = Workbook()
        table = get_Tables(table_one)
        table_to_sheet(table[0], wb)

        sheet = wb['simple table']  # Get sheet with the title `simple table`
        self.assertEqual(sheet['A1'].value, 'A cell')
        self.assertEqual(sheet['B1'].value, '=1+2')
        self.assertEqual(sheet['B1'].data_type, 's')
        self.assertEqual(sheet['B1'].number_format, 'General')
        self.assertEqual(sheet['C1'].value, '=1+2')
        self.assertEqual(sheet['C1'].data_type, 'f')
        self.assertEqual(sheet['C1'].number_format, '#,##0')
Example #4
0
    def test_table_to_sheet(self):
        wb = Workbook()
        table = get_Tables(table_one)
        table_to_sheet(table[0], wb)

        sheet = wb['simple table']  # Get sheet with the title `simple table`
        self.assertEqual(sheet['A1'].value, 'A cell')
        self.assertEqual(sheet['B1'].value, '=1+2')
        self.assertEqual(sheet['B1'].data_type, 's')
        self.assertEqual(sheet['B1'].number_format, 'General')
        self.assertEqual(sheet['C1'].value, '=1+2')
        self.assertEqual(sheet['C1'].data_type, 'f')
        self.assertEqual(sheet['C1'].number_format, '#,##0')
Example #5
0
def document_to_one_sheet_workbook(doc):
    wb = tablepyxl.Workbook()
    sheet = wb.active

    inline_styles_doc = Premailer(doc, remove_classes=False).transform()
    tables = get_Tables(inline_styles_doc)

    row = 1
    for table in tables:
        if table.head:
            row = write_rows(sheet, table.head, row)
        if table.body:
            row = write_rows(sheet, table.body, row)

    return wb
def document_to_one_sheet_workbook(doc):
    #Initiating the workbook and the worksheet
    wb = tablepyxl.Workbook()
    sheet = wb.active

    inline_styles_doc = Premailer(doc, remove_classes=False).transform()
    
    tables = get_Tables(inline_styles_doc)
    
    #Appending tables one below the other without leaving extra rows.
    #To append column wise, use write_columns
    
    row = 1
    for table in tables:
        if table.head:
            row = write_rows(sheet, table.head, row)
        if table.body:
            row = write_rows(sheet, table.body, row)
    
    return wb
Example #7
0
    def test_get_tables(self):
        doc = table_one
        self.assertEqual(len(get_Tables(doc)), 1)

        doc += doc
        self.assertEqual(len(get_Tables(doc)), 2)
Example #8
0
    def test_get_tables(self):
        doc = table_one
        self.assertEqual(len(get_Tables(doc)), 1)

        doc += doc
        self.assertEqual(len(get_Tables(doc)), 2)