1 #-*-coding:utf-8-*-2 3 ImportSYS4 ImportGlob5 ImportOS6 fromXlrdImportOpen_workbook7 ImportXLWT8 ImportPandas as PD9 fromXlutils.copyImportCopyTen ImportNumPy as NP One A Reload (SYS) -Sys.setdefaultencoding ("Utf-8" ) - the - defWrite_sheet (path,excel_name,name,index): -DF =Pd.read_excel (path,name) -list_sheet=[] + forNumberinchRange (0,len (df[0:])): - forIinchDf[0:].iloc[number]: + list_sheet.append (str (i)) A at PrintList_sheet -rb=Open_workbook (excel_name) -wb=copy (RB) -Ws=Wb.get_sheet (Index) -Number=0 - forIinchList_sheet: in ws.write (number,0,i) -Number=number+1 to Wb.save (excel_name) + - defSet_excel (excel_name,sheet_list): theI=0 * forNameinchsheet_list: $ ifi==0:Panax Notoginsengbook=XLWT. Workbook () - book.add_sheet (name) the Book.save (excel_name) +I=i+1 A Else: thesrc = Open_workbook (excel_name,formatting_info=True) +Destination =copy (SRC) - destination.add_sheet (name) $ Destination.save (excel_name) $ defMain (): -Homdir=OS.GETCWD () -Sour_dir=os.path.join (Homdir,"QCZSL") thePath_dir=os.path.join (Sour_dir,"*") - forPathinchGlob.glob (path_dir):WuyiExcel_name=path.split ("\\") [ -1].strip ("x") thesheet_list=Open_workbook (path). Sheet_names () - Set_excel (excel_name,sheet_list) Wu forNameinchsheet_list: -index=Sheet_list.index (name) About Write_sheet (Path,excel_name,name,index) $ Print "##########" - - if __name__=="__main__": -Main ()
Pandas/excel Get sheet name Modify data multiple sheet rows The column column sorted by one output