コード例 #1
0
def write_get_or_create_title(MD,
                              sheet,
                              sheet_of_copy_wb,
                              title_row,
                              fname=None):
    offset_write_xl = get_key(MD, 'offset_write_xl')
    offset_write_xl_diff = get_key(MD, 'offset_write_xl_diff')
    offset_write_xl_for_searched_obj = get_key(
        MD, 'offset_write_xl_for_searched_obj')
    check_file_write_more = get_key(MD, 'check_file_write_more')
    fname = fname or MD.get('model')
    sheet_ncols = sheet.ncols
    for k, v in [(offset_write_xl, u' có sẵn hay phải tạo'),
                 (offset_write_xl_for_searched_obj, u'theo cách tìm'),
                 (offset_write_xl_diff,
                  u'ở excel giống hay khác trong database')]:
        asmall_func(MD, fname, sheet_ncols, k, sheet_of_copy_wb, title_row, v)

    if check_file_write_more:
        for more_offset, func, more_title in check_file_write_more:
            col = sheet.ncols + more_offset
            title = more_title
            sheet_of_copy_wb.col(col).width = get_width(len(title))
            sheet_of_copy_wb.write(title_row, col, title, header_bold_style)

    if MD.get('fields'):
        for fname, field_MD in MD.get('fields').items():
            write_get_or_create_title(field_MD, sheet, sheet_of_copy_wb,
                                      title_row, fname)
コード例 #2
0
def write_get_or_create_title(MD, sheet, sheet_of_copy_wb, title_row):
    fields = MD['fields']
    for fname, field_MD in fields.items():
        offset_write_xl = get_key(field_MD, 'offset_write_xl')
        if offset_write_xl != None:
            col = sheet.ncols + offset_write_xl
            title = field_MD.get('string', fname) + u' sẵn hay tạo'
            sheet_of_copy_wb.col(col).width = get_width(len(title))
            sheet_of_copy_wb.write(title_row, col, title, header_bold_style)
        if field_MD.get('fields'):
            write_get_or_create_title(field_MD, sheet, sheet_of_copy_wb,
                                      title_row)
コード例 #3
0
def asmall_func(MD,
                fname,
                sheet_ncols,
                offset_write_xl,
                sheet_of_copy_wb,
                title_row,
                surfix=u' sẵn hay tạo'):
    if offset_write_xl != None:
        col = sheet_ncols + offset_write_xl
        title = 'Check ' + MD.get('string', fname) + surfix
        sheet_of_copy_wb.col(col).width = get_width(len(title))
        sheet_of_copy_wb.write(title_row, col, title, header_bold_style)