def test_check_xls_cells_alignment(self): data = get_valid_xls_data() workbook = Workbook(encoding='utf-8') worksheet_data = data.get(xls_build.WORKSHEETS_DATA)[0] _build_worksheet(worksheet_data, workbook, 0) alignments = workbook._alignments[1] self.assertEqual(alignments.horizontal, 'left') self.assertEqual(alignments.vertical, 'top')
def _create_xls(parameters_dict): workbook = Workbook(encoding='utf-8') sheet_number = 0 for worksheet_data in parameters_dict.get(xls_build.WORKSHEETS_DATA): xls_build._build_worksheet(worksheet_data, workbook, sheet_number) sheet_number = sheet_number + 1 _build_worksheet_parameters(workbook, parameters_dict.get(xls_build.USER_KEY), parameters_dict.get("operation", ""), parameters_dict.get("research_criteria")) return save_virtual_workbook(workbook)
def _get_workbook(egy, excel_lines, workbook, worksheet_title, end_column): header, *content = [tuple(line) for line in excel_lines] style = _get_style_to_apply(excel_lines) worksheet_data = { WORKSHEET_TITLE_KEY: worksheet_title, HEADER_TITLES_KEY: header, CONTENT_KEY: content, STYLED_CELLS: style } _build_worksheet(worksheet_data, workbook, 0) _merge_cells(excel_lines, workbook, end_column) _add_hyperlink(excel_lines, workbook, str(egy.academic_year.year)) return workbook
def test_adjust_row_height(self): data = {xls_build.LIST_DESCRIPTION_KEY: 'Liste de cours', xls_build.FILENAME_KEY: 'fichier_test', xls_build.USER_KEY: 'Dupuis', xls_build.WORKSHEETS_DATA: [{xls_build.CONTENT_KEY: [['Col1 Row1']], xls_build.HEADER_TITLES_KEY: ['Acronym'], xls_build.ROW_HEIGHT: {'height': 30, 'start': 1, 'stop': 3} }, ]} workbook = Workbook(encoding='utf-8') worksheet_data = data.get(xls_build.WORKSHEETS_DATA)[0] _build_worksheet(worksheet_data, workbook, 0) self.assertEqual(workbook.worksheets[0].row_dimensions[1].height, 30) self.assertEqual(workbook.worksheets[0].row_dimensions[2].height, 30) self.assertEqual(workbook.worksheets[0].row_dimensions[3].height, 30) self.assertNotEqual(workbook.worksheets[0].row_dimensions[4].height, 30)
def _get_workbook_for_custom_xls(excel_lines, need_proposal_legend, colored_cells, row_height=dict()): workbook = Workbook() worksheet_title = clean_worksheet_title(_("List UE")) header, *content = [tuple(line) for line in excel_lines] worksheet_data = { WORKSHEET_TITLE_KEY: worksheet_title, HEADER_TITLES_KEY: header, CONTENT_KEY: content, STYLED_CELLS: {}, COLORED_ROWS: colored_cells, ROW_HEIGHT: row_height, } _build_worksheet(worksheet_data, workbook, 0) if need_proposal_legend: _build_worksheet(prepare_proposal_legend_ws_data(), workbook, 1) return workbook