def TestInput(data): fdp = atheris.FuzzedDataProvider(data) try: cell.absolute_coordinate(fdp.ConsumeString(20)) cell.cols_from_range(fdp.ConsumeString(20)) cell.column_index_from_string(fdp.ConsumeString(20)) cell.coordinate_from_string(fdp.ConsumeString(20)) cell.coordinate_to_tuple(fdp.ConsumeString(20)) cell.get_column_interval(fdp.ConsumeInt(10),fdp.ConsumeInt(10)) cell.get_column_letter(fdp.ConsumeInt(10)) cell.quote_sheetname(fdp.ConsumeString(20)) cell.range_boundaries(fdp.ConsumeString(20)) cell.range_to_tuple(fdp.ConsumeString(20)) cell.rows_from_range(fdp.ConsumeString(20)) except ValueError as e: error_list = [ "is not a valid coordinate range", "Invalid column index", "is not a valid column name", "is not a valid coordinate or range", "Value must be of the form sheetname!A1:E4" ] expected_error = False for error in error_list: if error in str(e): expected_error = True if not expected_error: raise e except CellCoordinatesException: pass
def print_table_headers(work_sheet, courses, start): check_points = CheckPoint.objects.all() work_sheet.cell(row=start, column=1).value = '№' work_sheet.merge_cells(start_row=start, start_column=1, end_row=start+1, end_column=1) work_sheet.cell(row=start, column=2).value = 'Фамилия, имя, отчество' work_sheet.merge_cells(start_row=start, start_column=2, end_row=start + 1, end_column=2) work_sheet.cell(row=start, column=3).value = '№ зачетной книжки' work_sheet.merge_cells(start_row=start, start_column=3, end_row=start + 1, end_column=3) work_sheet.cell(row=start, column=1).alignment = Alignment(wrap_text=True, vertical='center', horizontal='center') work_sheet.cell(row=start, column=2).alignment = Alignment(wrap_text=True, vertical='center', horizontal='center') work_sheet.cell(row=start, column=3).alignment = Alignment(wrap_text=True, vertical='center', horizontal='center') col = 4 for course_id in courses.keys(): work_sheet.cell(row=start, column=col).value = courses[course_id] work_sheet.merge_cells(start_row=start, start_column=col, end_row=start, end_column=col+2) work_sheet.cell(row=start, column=col).alignment = Alignment(wrap_text=True, vertical='center', horizontal='center', text_rotation=90) max_points = dict(CourseMaxPoints.objects.filter(course__id=course_id).values_list('checkpoint__id', 'max_point')) for check_point in check_points: max_point = str(max_points[check_point.id]) if check_point.id in max_points.keys() else '' work_sheet.cell(row=start + 1, column=col).value = check_point.name + ' max=' + max_point work_sheet.cell(row=start + 1, column=col).alignment = Alignment(wrap_text=True, vertical='center', horizontal='center', text_rotation=90) col += 1 work_sheet.cell(row=start, column=col).value = 'Пропущено всего/в т.ч. по уважительной причине' work_sheet.cell(row=start, column=col).alignment = Alignment(wrap_text=True, vertical='center', horizontal='center', text_rotation=90) work_sheet.merge_cells(start_row=start, start_column=col, end_row=start, end_column=col + 2) work_sheet.column_dimensions['A'].width = 5 work_sheet.column_dimensions['B'].width = 35 work_sheet.column_dimensions['C'].width = 10 max_column = (len(courses) + 2) * 3 for column in get_column_interval(start=4, end=max_column): work_sheet.column_dimensions[column].width = 5 work_sheet.row_dimensions[start].height = 80 work_sheet.row_dimensions[start + 1].height = 80
def print_exam_table_headers(work_sheet, courses, start): work_sheet.cell(row=start, column=1).value = '№' work_sheet.cell(row=start, column=2).value = 'Фамилия, имя, отчество' work_sheet.cell(row=start, column=3).value = '№ зачетной книжки' work_sheet.cell(row=start, column=1).alignment = Alignment(wrap_text=True, vertical='center', horizontal='center') work_sheet.cell(row=start, column=2).alignment = Alignment(wrap_text=True, vertical='center', horizontal='center') work_sheet.cell(row=start, column=3).alignment = Alignment(wrap_text=True, vertical='center', horizontal='center') col = 4 for course_id in courses.keys(): work_sheet.cell(row=start, column=col).value = courses[course_id] work_sheet.cell(row=start, column=col).alignment = Alignment(wrap_text=True, vertical='center', horizontal='center', text_rotation=90) col += 1 work_sheet.column_dimensions['A'].width = 5 work_sheet.column_dimensions['B'].width = 45 work_sheet.column_dimensions['C'].width = 10 max_column = len(courses) + 3 for column in get_column_interval(start=4, end=max_column): work_sheet.column_dimensions[column].width = 10 work_sheet.row_dimensions[start].height = 90
def load_workbook_range(range_string, ws): col_start, col_end = re.findall("[A-Z]+", range_string) data_rows = [] for row in ws[range_string]: data_rows.append([cell.value for cell in row]) return pd.DataFrame(data_rows, columns=get_column_interval(col_start, col_end))