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')
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')
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
def test_get_tables(self): doc = table_one self.assertEqual(len(get_Tables(doc)), 1) doc += doc self.assertEqual(len(get_Tables(doc)), 2)