def __copy_from_tem(self): yerorno = self.__dictconf["copy_from_tem"] startcopyrange = self.__dictconf["sub_copy_from_tem_startcopyrange"] startpasterange = self.__dictconf["sub_copy_from_tem_startpasterange"] namesheet_tem = self.__dictconf["sub_copy_from_tem_namesheet_tem"] if self.__retr_sheetname == "Active Sheet": ws_retr = activesheet() cprange_2wb(pathtocopy=self.__path_exell_tem, range_copy=startcopyrange[0], sheet_des=ws_retr, range_paste=startpasterange[0], clear_rcopy_after_copy=False, sheetname_tem=namesheet_tem[0]) else: wb_retr = open_wb_by_xl(pathex=self.__retr_path, cre_new_app=False, visible=True, add_book=False) lsheet = listsheet_by_wb(wb_retr) for nsheet in lsheet: if self.__retr_sheetname in nsheet: wb_retr.sheets[nsheet].activate() ws_retr = activesheet() cprange_2wb(pathtocopy=self.__path_exell_tem, range_copy=startcopyrange[0], sheet_des=ws_retr, range_paste=startpasterange[0], clear_rcopy_after_copy=False, sheetname_tem=namesheet_tem[0])
def __init__(self, pathconf=None): self.__pathconf = pathconf dictconf = returndictrowforcsv(path=pathconf) self.__hm_congtac = dictconf["hm_congtac"] self.__hm_bombt = dictconf["hm_bombt"] self.__hm_macmtc = dictconf["hm_macmtc"] self.__hm_materiasvattu = dictconf["hm_materiasvattu"] self.__hm_vlvk = dictconf["hm_vlvk"] self.__hm_VLTP = dictconf["hm_vltp"] self.__hm_MNCTP = dictconf["hm_mnctp"] self.__hm_VTKCT = dictconf["hm_vtkct"] self.__hm_NCKCT = dictconf["hm_nckct"] self.__hm_startpasterange = dictconf["hm_startpasterange"] sign_vk = dictconf["sign_vk"].replace(":", ",") self.sign_vk = returnlist_from_listinstr(sign_vk) sign_BT = dictconf["sign_bt"].replace(":", ",") self.sign_BT = returnlist_from_listinstr(sign_BT) self.__startpasterange = returnseplistintbbystr( self.__hm_startpasterange) self.pathlsn = refullpath(dirpath=getdirpath(pathconf), filename=dictconf["listsheetnamehm"]) fct = dictconf["fct"] try: self.lsheetname = convertcsvto1list(path=self.pathlsn) except: pass fname = dictconf["khns_namfile"] if fct.strip() == "all": self.wb = activeworkbook(namefile=fname, checknamefile=True) for sheet in self.lsheetname: print(sheet) self.wb.sheets[sheet].activate() self.__sheetdesactive = activesheet() self.m_row = self.__sheetdesactive.range( self.__hm_congtac + str(self.__sheetdesactive.cells.last_cell.row)).end( 'up').row self.__hdata() #self.copyrangfromconf() else: self.__sheetdesactive = activesheet() #self.copyrangfromconf() self.m_row = self.__sheetdesactive.range( self.__hm_congtac + str(self.__sheetdesactive.cells.last_cell.row)).end('up').row self.__hdata()
def copyrangfromconf(self): # return csv have list sheet name try: self.lsheetname = convertcsvto1list(path=self.pathlsn) except: pass if self.copyhm.strip() == "all": self.wb = activeworkbook(namefile=self.fname, checknamefile=True) for sheet in self.lsheetname: self.wb.sheets[sheet].activate() self.__sheetdesactive = activesheet() self.__copyrangfromconfk() else: self.__sheetdesactive = activesheet() self.__copyrangfromconfk()
def __init__( self, retr_path=None, retr_sheetname=None, des_path=None, des_sheetname=None, fuction=None, pathconf=None, ): self.dictconf = returndictrowforcsv(path=pathconf) self.__retr_sheetname = retr_sheetname self.__des_path = des_path self.__des_sheetname = des_sheetname self.__fuction = fuction if retr_sheetname == "Active Sheet": retr_path = activeworkbook_fullname() retr_sheetname = activesheet_name() self.__pexcelretr = repathlinkexcel(usingfullname=True, fullname=retr_path, namesheet=retr_sheetname) if des_sheetname == "Active Sheet": self.__ws_des = activesheet() else: self.__ws_des = sheet_by_namesheet(path=des_path, namesheet=des_sheetname)
def valuehangmucforthvt(self): """ value from hang muc for thvt """ valuefthvt = self.dicrowconf["valuefthvt"] if valuefthvt.strip() == "all": self.wb = activeworkbook(namefile=self.__namefile, checknamefile= True) for sheet in self.lsheetname: self.wb.sheets[sheet].activate() self.sht1 = activesheet() self.sheetnameactive = self.sht1.name self.valuehmnvn() else: self.sht1 = activesheet() self.sheetnameactive = self.sht1.name self.valuehmnvn()
def gdatafromothersheet (self, realtime = True): """ get data from mothers sheet """ # clear hm beforecopy #hm_startpasterange = self.dicrowconf["hm_startpasterange_bt"] #self.sht1.range(hm_startpasterange).api.Delete() updatedata = self.dicrowconf["updatedata"] if updatedata.strip() == "all": self.wb = activeworkbook(namefile=self.__namefile, checknamefile= True) for sheet in self.lsheetname: print (sheet) self.wb.sheets[sheet].activate() self.sht1 = activesheet() self.sheetnameactive = self.sht1.name self.updatavalue() else: self.sht1 = activesheet() self.sheetnameactive = self.sht1.name self.updatavalue()
def __transfertoparents(self): for name_ele_ex in self.__lsheet_ex: path_copy = refullpath(dirpath=self.__path_copy_dir, filename=name_ele_ex) copyxw = self.__app.books.open(fullname=path_copy, update_links=False, read_only=False, ignore_read_only_recommended=False) lkeys = list(self.__dictconf.keys()) # lengh of sheet name key llen = len("sub_transfertoparents_namesheet") key_snames = [ lkey[llen:] for lkey in lkeys if "sub_transfertoparents_namesheet" in lkey ] yerorno = self.__dictconf["transfertoparents"] for key_sname in key_snames: sheetname = self.__dictconf["sub_transfertoparents_namesheet" + key_sname] nstart_row = int( self.__dictconf["sub_transfertoparents_recor_l1" + key_sname]) valueim = self.__dictconf["sub_transfertoparents_valueim" + key_sname] msstr = self.__dictconf["sub_transfertoparents_ms" + key_sname] for_using_loc = self.__dictconf[ "sub_transfertoparents_forbydup" + key_sname] loc_use_formulas = self.__dictconf[ "sub_transfertoparents_locuseformulas" + key_sname] col_dup = self.__dictconf["sub_transfertoparents_dup" + key_sname] ws_copy = retrive_sname_sheet(copyxw=copyxw, desxw=self.__desxw, lsheet=[sheetname]) # check ws_copy if ws_copy == None: continue # retrive sheet des and active self.__desxw.sheets[ws_copy.name].activate() # transer range using VLOOLUP hchildsheet(startrow=nstart_row, col_key_msa=msstr, lcolumnformulas=loc_use_formulas, valueim=valueim, sheet_des=activesheet(), sheet_copy=ws_copy, col_dup=col_dup, formulasfor_col_dup=for_using_loc ) if yerorno == "yes" else False copyxw.close() self.__desxw.save() self.__desxw.close() self.__app.quit()
def __transfertoparent(self): lsheet = self.__dictconf["sub_transfertoparent_listsheetname"] for name_ele_ex in self.__lsheet_ex: path_copy = refullpath(dirpath=self.__path_copy_dir, filename=name_ele_ex) copyxw = self.__app.books.open(fullname=path_copy, update_links=False, read_only=False, ignore_read_only_recommended=False) ws_copy = retrive_sname_sheet(copyxw=copyxw, desxw=self.__desxw, lsheet=lsheet) # check ws_copy if ws_copy == None: continue # retrive parameter from file excel config yerorno = self.__dictconf["transfertoparent"] nstart_row = int(self.__dictconf["sub_transfertoparent_recor_l1"]) valueim = self.__dictconf["sub_transfertoparent_valueim"] msstr = self.__dictconf["sub_transfertoparent_ms"] for_using_loc = self.__dictconf["sub_transfertoparent_forbydup"] loc_use_formulas = self.__dictconf[ "sub_transfertoparent_locuseformulas"] col_dup = self.__dictconf["sub_transfertoparent_dup"] # retrive sheet des and active self.__desxw.sheets[ws_copy.name].activate() ws_des = activesheet() hchildsheet(startrow=nstart_row, col_key_msa=msstr, lcolumnformulas=loc_use_formulas, valueim=valueim, sheet_des=activesheet(), sheet_copy=ws_copy, col_dup=col_dup, formulasfor_col_dup=for_using_loc ) if yerorno == "yes" else False copyxw.close() self.__desxw.save() self.__desxw.close() self.__app.quit()
def __init__(self, retr_path = None, retr_sheetname =None, fuction = None, pathconf = None, ): self.dictconf = dict_str_fromlist(path=pathconf) self.__retr_sheetname = retr_sheetname self.__fuction = str(fuction).lower() if retr_sheetname == "Active Sheet": self.__ws_retr = activesheet() else: self.__ws_retr = sheet_by_namesheet(path=retr_path, namesheet=retr_sheetname)
def __init__(self, retr_path = None, retr_sheetname =None, fuction = None, pathconf = None, path_exell_tem = None ): self.__dictconf = dict_str_fromlist(path=pathconf) self.__path_exell_tem = path_exell_tem self.__retr_sheetname = retr_sheetname self.__fuction = str(fuction).lower() if retr_sheetname != "Active Sheet": sheet_by_namesheet(path=retr_path, namesheet=retr_sheetname).activate() self.__ws_retr = activesheet()
def __init__( self, retr_path=None, retr_sheetname=None, fuction=None, pathconf=None, ): self.__dictconf = dict_str_from_lcsv(path=pathconf) self.__retr_sheetname = retr_sheetname self.__fuction = fuction if retr_sheetname == "Active Sheet": self.__ws_retr = activesheet() else: self.__ws_retr = sheet_by_namesheet(path=retr_path, namesheet=retr_sheetname)
def __init__( self, retr_path=None, retr_sheetname=None, fuction="", pathconf=None, ): self.__retr_sheetname = retr_sheetname self.__fuction = fuction.lower() # Create a dict have parameter from csv self.__dictconf = dict_str_from_lcsv(path=pathconf) # Option from user input (Active Sheet or not) self.__ws_retr = activesheet() if retr_sheetname == "Active Sheet"\ else sheet_by_namesheet(path=retr_path, namesheet=retr_sheetname ) # Check file excel execute is conf_ex.xlsx or not if self.__ws_retr.name == "hrdata_modified": messagebox.showerror( "Error Name Excel", "Can not using file excel: conf_ex.xlsx to execute. \ Check again {}".format("hrdata_modified"))