패키지 응용 프로그램 창 exe 인 파이썬 GUI 프로그래밍 코드

내 동료 코드의 사용에 익숙하지 않은에 대한 비즈니스 요구 사항으로, VBA는 적합하지 않을 수 있습니다

원래의 포장 및 파이썬 코드에 따라서 VBA 코드를 개선하기 위해 다음 기회를 수행

 

전체 코드

오기 xlrd하는
 오기 xlwt를
 으로부터 xlutils.copy 오기 복사
 로부터 Tkinter를 가져 * DEF : runl () 
    QT1, Qt2 = 0,0
     # 오픈 형식 은 try : 
        통합 = xlrd.open_workbook (R & LT ' fendan.xlsx \\. ' )
     를 제외하고을 : 
        TXT를 를 취소하려면 (END, ' 열린 테이블은 테이블 fendan.xlsx 생성되어 있는지 확인 실패 ' ) 
        txt.insert (END를, ' 그 \ N- ' ) #이 이름 얻을 
    sheet_names을 =



    
        
    workbook.sheet_names ()
     # 获取对象 
    시트 1 workbook.sheet_by_name = ( ' 시트 1 ' ) 

    # #wb xlwt.Workbook = (R '. \\ fendan.xlsx') 
    # #ws wb.get_sheet = (0) 
    WRITE_DATA = 복사 ( 통합) 
    write_save = write_data.get_sheet (0) 

    NROWS = sheet1.nrows 
    
    # 前处理,将号取消尾数订单
    위한 I  범위 (1 , NROWS)
         경우  되지 sheet1.cell_value (행 x = 1, colx = 1) : 10] == ' :
 #의 # 전단 (sheet1.cell_value (행 x = 1, colx = 1) [10]) 
            #난 103 행 수를 기록하기 전에 두 i 행을 
            write_save.write (I 2 sheet1.cell_value을 (ⅰ = 행 x, COLX = 1). [10 ]) 
    write_data.save ( ' fendan2.xlsx ' ) 

    # 테이블 열기 
    Workbook2 xlrd.open_workbook = (R & LT ' . fendan2.xlsx \\ ' ) 

    # 1 오브젝트 얻을 
    시트 2 workbook2.sheet_by_name = ( ' 시트 1 ' ) 
    write_data2 = 복사 (Workbook2) 
    write_save2 = write_data2.get_sheet (0) 
    
    #에 설정된 쓰기 패턴으로. 1 
    font0 = xlwt.Font () 
    patter1을 = xlwt.Pattern ()
    pattern1.pattern  =xlwt.Pattern.SOLID_PATTERN 
    pattern1.pattern_fore_colour = 5 
    style0 = xlwt.XFStyle () 
    style0.pattern = patter1을
     # 设置写入样式2 
    하는 pattern2 = xlwt.Pattern () 
    pattern2.pattern = xlwt.Pattern.SOLID_PATTERN 
    pattern2.pattern_fore_colour = 5 
    pattern2.pattern_fore_colour = 2 
    을 Style1 = xlwt.XFStyle () 
    style1.pattern = 하는 pattern2 
    NROWS = sheet2.nrows
     대한 K  범위를 (1 , NROWS)
        위한 연구  범위 (1 , NROWS)
             경우  되지 sheet2.cell_value (행 x = K, colx = 2) == ' :
 #의 # 잉크 (K, R) 
                의 경우 sheet2.cell_value (행 x = R, colx = 2) == sheet2.cell_value (행 x = K, colx = 5 ) :
 #의 # 전단 (sheet2.cell_value (행 x = R, colx = 2), sheet2.cell_value (행 x = K, colx = 5)) 
#의 # 전단 (시트 2 .cell_value (행 x = R, colx = 2) == sheet2.cell_value (행 x = K, colx = 5)) 
                    의 경우 sheet2.cell_value (행 x = R, colx = 3) == sheet2.cell_value (행 x = K, colx = 6 ) :
 #의# 전단 (sheet2.cell_value (행 x = R, colx = 3) sheet2.cell_value (행 x = K, colx = 6)) 
#의 # 전단 (sheet2.cell_value (행 x = R, colx = 3) == sheet2.cell_value (행 x = K, colx = 6)) 
                        write_save2.write (R, 2 sheet2.cell_value (행 x = R, colx = 2) = 스타일 style0) 
                        write_save2.write (R, 3 sheet2.cell_value (행 x = R , colx = 3), 스타일 = style0) 
                        write_save2.write (K, 5 sheet2.cell_value (행 x = K, colx = 5) = 스타일 을 Style1) 
                        write_save2.write (K, 6 sheet2.cell_value (행 x = K , colx = 6) = 스타일 을 Style1) 
                        QT1 = QT1 + sheet2.cell_value (행 x = R, colx = 3 )
                        qt2 = qt2 + sheet2.cell_value (행 x = K, colx = 6 )
     #의 # 전단 (sheet1.row_values (행 x = R, start_colx = 2 end_colx = 7)) 
    write_data2.save ( ' fendan2.xlsx ' )
 #의 # 프린트 (QT1, qt2) 
    txt.insert (END, ' 区分完毕' ) 
    txt.insert (END, ' n \ ' ) 
    txt.insert (END (QT1, qt2)) 
    txt.insert (END, ' n \ ' ) 

루트 = TK에 () 
root.title ( ' 区分订单' ) 
root.geometry ( ' 460x300 ' ) 

LB1 = 레이블 (루트, 텍스트 = 'Excel 스프레드 시트, 각각 세 번째, 네, 여섯, 일곱 및 주문 번호를 입력하세요 ' ) 
lb1.place (RelX에 의존 = 0.1 = 0.1, relwidth = 0.8, relheight = 0.1 ) 

인 btn1 = 버튼 (루트, 텍스트 = ' 버튼을 클릭 닫기를 입력 Excel 스프레드 시트를 끝 ' , 명령 = runl) 
btn1.place (RelX에 , = 0.2를 0.2 = 의존 relwidth = 0.6, relheight는 = 0.3 ) 

TXT는 = 텍스트 (루트) 
txt.place이 (의지 할 = 0.6, = 0.3 relheight ) 

(LB2)은 라벨 (루트, 텍스트 = " OF : YBX의 ' ) 
lb2.place (RelX에 = 0.8을 의지 = 0.9, relwidth = 0.2, relheight = 0.1) 

Root.mainloop ()
Excel 스프레드 시트 두 개의 디지털 교정 기능을하고 EXE를 포장한다

 

그는 다음 참조에 감사를 표 :

https://www.jianshu.com/p/91844c5bca78

https://www.cnblogs.com/jackzz/p/9431923.html

추천

출처www.cnblogs.com/ybxw/p/11605177.html