예제 #1
0
    def __init__(
        self,
        pathconf=None,
        pathdes=None,
        pathtocopy=None,
    ):
        # call dict
        self.dictconf = returndictrowforcsv(path=pathconf)
        # return list sheet excel to handling
        self.__pathdes = pathdes
        self.__pathtocopy = pathtocopy
        self.__app = xw.App(visible=True, add_book=False)
        self.__desxw = self.__app.books.open(fullname=self.__pathdes,
                                             update_links=False)
        self.__copyxw = self.__app.books.open(
            fullname=self.__pathtocopy,
            update_links=False,
            read_only=False,
            ignore_read_only_recommended=False)
        self.wsnames = self.__copyxw.sheets
        for namesheet in self.wsnames:
            if "AZB" in namesheet.name:
                self.ws_copy = namesheet
                break

        #max row ws1
        self.rows = self.ws_copy.api.UsedRange.Rows.count
        #max colum ws1
        self.cols = self.ws_copy.api.UsedRange.Columns.count
        self.colunsande = [colnum_string(1), colnum_string(self.cols)]
        # name sheet
        self.__namesheet = self.ws_copy.name
        # set active sheet name
        self.__desxw.sheets[self.__namesheet].activate()
예제 #2
0
 def __init__(self,
              pathtocopy=None,
              namesheetchild="AZB",
              pathconf=None,
              diplaywindow=None):
     self.diplaywindow = diplaywindow
     self.pathconf = pathconf
     self.pathtocopy = pathtocopy
     self.namesheetchild = namesheetchild
     self.dicrowconf = returndictrowforcsv(path=pathconf)
     self.__namefile = self.dicrowconf["khns_namfile"]
     self.__Getlistsheet()
예제 #3
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()
예제 #4
0
 def __init__(self, pathconf=None, pathconfigexcelcopy=None):
     # call dict
     self.pathconfigexcelcopy = pathconfigexcelcopy
     dictconf = returndictrowforcsv(path=pathconf)
     self.__hm_startcopyrange = dictconf["hm_startcopyrange"]
     self.fname = dictconf["khns_namfile"]
     self.__startcopyrange = returnseplistintbbystr(
         self.__hm_startcopyrange)
     self.__hm_startpasterange = dictconf["hm_startpasterange"]
     self.__hm_hangmuc = dictconf["hm_hangmuc"]
     # copy another range botton
     self.__hm_startcopyrangebt = dictconf["hm_startcopyrange_bt"]
     self.__startcopyrangebt = returnseplistintbbystr(
         self.__hm_startcopyrangebt)
     self.__hm_startpasterangebt = dictconf["hm_startpasterange_bt"]
     self.pathlsn = refullpath(dirpath=getdirpath(pathconf),
                               filename=dictconf["listsheetnamehm"])
     self.copyhm = dictconf["copyhm"]
예제 #5
0
    def __init__(self, pathconf=None):
        self.__pathconf = pathconf
        dirparhconf = parentdirectory(self.__pathconf)
        dicrowconf = returndictrowforcsv(path=pathconf)
        self.__sheetnametor = dicrowconf["khns_sheetnamekhns"]
        self.__khns_namfile = dicrowconf["khns_namfile"]
        self.__khns_rangenumbermct_ptvt = dicrowconf[
            "khns_rangenumbermct_ptvt"]
        self.__valuenotnone = dicrowconf["valuenotnone"]
        self.__valueall = dicrowconf["valueall"]
        self.__dictvalue = dicrowconf["dictvalue"]
        self.__mvta = (dicrowconf["khns_mavatu"])
        self.__mvt = col2num(self.__mvta)

        #self.__fpath = returnactivewbpath(namefile=self.__khns_namfile)
        self.__fpath = activeworkbook_fullname()

        self.__rel = credict(pathfull=self.__fpath,
                             namesheet=self.__sheetnametor,
                             engine="xlwings",
                             rangea=self.__khns_rangenumbermct_ptvt)
        # csv for dict
        self.pathtovalue = refullpath(dirparhconf, self.__dictvalue)
        # csv for value
        self.valuenotnone = refullpath(dirparhconf, self.__valuenotnone)

        # csv for all value
        self.pathvalueall = refullpath(dirparhconf, self.__valueall)

        # get all key redic incule len != 0
        self.redic_all = self.__rel.redictvaluesandvaluecol(
            columnumber=self.__mvt, removeemtyvalue=False)

        #self.redic =self.__rel.redictvaluesandvaluecol(columnumber=self.__mvt)

        self.redic = {
            key: val
            for key, val in self.redic_all.items() if len(val) != 0
        }

        self.valueredicttocsv()
        self.valuelisttocsv()
예제 #6
0
    def __init__(
        self,
        pathconf=None,
        pathdes=None,
        pathtocopy=None,
    ):
        # call dict
        self.dictconf = returndictrowforcsv(path=pathconf)
        # return list sheet excel to handling
        self.__pathdes = pathdes
        self.__pathtocopy = pathtocopy
        self.__app = xw.App(visible=True, add_book=False)
        self.__desxw = self.__app.books.open(fullname=self.__pathdes,
                                             update_links=False)

        self.__copyxw = self.__app.books.open(
            fullname=self.__pathtocopy,
            update_links=False,
            read_only=False,
            ignore_read_only_recommended=False)
        self.wsnames = self.__copyxw.sheets
        for namesheet in self.wsnames:
            if "AZB" in namesheet.name:
                self.ws1 = namesheet
                break
        # list sheet name
        listsheetex = list_from_listinstr(
            self.dictconf["listsheetnamechild"].replace(":", ","))
        # name sheet
        self.__namesheet = self.ws1.name
        # set active sheet name
        self.__desxw.sheets[self.__namesheet].activate()
        print("sheet name", self.__namesheet)
        # check name sheet name
        if self.__namesheet not in listsheetex:
            messagebox.showerror(
                "error", "name sheet {0} of workbook{1} not valid, its \
                                    name is AZB-NN".format(
                    self.__namesheet, pathtocopy))
예제 #7
0
from pynvn.excel.copypasteexell import cprange
import xlwings as xw
from pynvn.csv.rcsv import returndictrowforcsv
from pynvn.string.slist import returnseplistintbbystr
from pynvn.excel import activesheet,activeworkbook
from pynvn.csv.tolist import convertcsvto1list
from pynvn.path.ppath import refullpath,getdirpath
def conf_csvtolist (pathconf,path_csvtoconverttolist)
    """ copy sheet and change value cell """
    # call dict 
    dictconf = returndictrowforcsv(path=pathconf)
    # return csv have list sheet name 
    self.pathlsn = refullpath(dirpath=self.dirpathconf,
                                        filename=listsheetnamehm)
    copyhm = dictconf["copyhm"]
    try:                        
        self.lsheetname = convertcsvto1list(path=path_csvtoconverttolist)
    except:
        pass
예제 #8
0
    def guiforgd(self):
        """Create interface for software"""
        gui(tktk=self.root,
            pathico=None,
            width=700,
            height=420,
            widthx=420,
            widthy=0,
            resizable=[True, True],
            title="FAPP").setcfbs()

        self.sc = scbg(
            parent=self.root,
            cavheight=250,
            cavwidth=365,
            isonlyaframe=False,
            bg="#e6ecf5",
            bgpr="#5b9bd5",
            framea=[0, 0, 365, 250, "#e6ecf5"],
        )
        large_font = ("times new roman", 12)
        large_font_1 = ("times new roman", 17)
        lb = tk.Label(self.root,
                      text="Mr.Nhuần - [email protected]",
                      font=large_font,
                      bg="#5b9bd5")
        lb.place(relx=0.5, rely=0.87, anchor=tk.CENTER)

        self.framea = self.sc.framea

        lbt = tk.Label(
            self.framea,
            bg="#e6ecf5",
            fg="black",
            text="Input your information",
            font=large_font_1,
        )
        lbt.grid(row=0, column=0, columnspan=6, sticky=tk.EW)
        # path to folder child
        repath = tk.Label(
            self.framea,
            text="Retrieve Path:",
            width=10,
            font=large_font,
            bg="#e6ecf5",
        )
        repath.grid(row=1, column=0, sticky=tk.W, padx=(5, 0))

        self.output1 = tk.Entry(
            self.framea,
            font=large_font,
            justify=tk.CENTER,
            width=20,
            relief=tk.SOLID,
            bg="yellow",
        )
        self.output1.grid(row=2, column=0, padx=(5, 0))

        button = tk.Button(self.framea,
                           height=1,
                           width=2,
                           bd=1,
                           command=lambda: self.mfileopend(
                               outputtk=self.output1, combopc=self.combopc))
        button.grid(row=2, column=1, sticky="we")

        lsheets = None
        self.pc = tk.StringVar()
        self.combopc = ttk.Combobox(
            self.framea,
            textvariable=self.pc,
            width=20,
            values=["Active Sheet", "Select Sheet Name"],
            state="readonly",
            justify='center')

        self.combopc.grid(column=2, row=2, padx=(10, 0))

        self.combopc.bind("<<ComboboxSelected>>", self.selected_rev)
        self.combopc.current(1)

        # destination
        repathdes = tk.Label(
            self.framea,
            text="Destination Path:",
            font=large_font,
            bg="#e6ecf5",
        )
        repathdes.grid(row=3, column=0, sticky=tk.W, pady=(5, 0), padx=(5, 0))

        self.repathdes = tk.Entry(
            self.framea,
            font=large_font,
            justify=tk.CENTER,
            relief=tk.SOLID,
            bg="yellow",
        )
        self.repathdes.grid(row=4, column=0, sticky=tk.EW, padx=(5, 0))

        buttondes = tk.Button(
            self.framea,
            height=1,
            width=4,
            bd=1,
            command=lambda: self.mfileopend(outputtk=self.repathdes,
                                            combopc=self.combo_des))
        buttondes.grid(row=4, column=1, sticky="we")

        self.pc_des = tk.StringVar()
        self.combo_des = ttk.Combobox(
            self.framea,
            textvariable=self.pc_des,
            width=15,
            values=["Active Sheet", "Select Sheet Name"],
            state="readonly",
            justify='center')
        self.combo_des.grid(column=2, row=4, sticky=tk.EW, padx=(10, 0))

        self.combo_des.current(1)

        self.combo_des.bind("<<ComboboxSelected>>", self.selected_des)

        func = tk.Label(
            self.framea,
            text="Function Excel:",
            font=large_font,
            bg="#e6ecf5",
        )
        func.grid(row=5, column=0, sticky=tk.W, padx=(5, 0))
        self.pc_fun = tk.StringVar()

        lfun = ["Select Function In Excel"] + filterlistbylstr(
            liststr=list(returndictrowforcsv(self.pathconfig).keys()),
            criteria_is_not=True,
            criteria=["sub_"],
            upper=True)
        self.combo_fun = ttk.Combobox(self.framea,
                                      textvariable=self.pc_fun,
                                      width=15,
                                      values=lfun,
                                      state="readonly",
                                      justify='center')
        self.combo_fun.grid(column=0,
                            row=6,
                            columnspan=3,
                            sticky=tk.EW,
                            padx=(5, 0))

        self.combo_fun.current(0)

        self.combo_fun.bind("<<ComboboxSelected>>", self.selected_des)

        button_open = tk.Button(
            self.framea,
            height=1,
            width=8,
            text="Open_Conf",
            bd=1,
            command=lambda: openexcelbyxl(self.pathconfigexell))
        button_open.grid(row=7, column=0, sticky="w", padx=(5, 0))

        button_conf = tk.Button(
            self.framea,
            height=1,
            width=8,
            text="Up_Conf",
            bd=1,
            command=lambda: hconfazb(pathconf=self.pathconfig,
                                     pathexconf=self.pathconfigexell
                                     ).convertocsv())
        button_conf.grid(row=7, column=2, sticky="e")

        run = tk.Button(self.framea,
                        height=1,
                        width=4,
                        text="Run",
                        bd=1,
                        command=lambda: fformulas(
                            retr_path=getpathfromtk(
                                self.output1, Warning_path_existing=False),
                            des_path=getpathfromtk(
                                self.repathdes, Warning_path_existing=False),
                            retr_sheetname=self.pc.get(),
                            des_sheetname=self.pc_des.get(),
                            fuction=self.pc_fun.get(),
                            pathconf=self.pathconfig).filltoexcell())
        run.grid(row=9, column=1, sticky="e")

        run = tk.Button(self.framea,
                        height=1,
                        width=4,
                        text="Quit",
                        bd=1,
                        command=self.root.quit)
        run.grid(row=10, column=1, sticky="e")
예제 #9
0
    def __init__ (self, fpath = None,
                        pathconf = None,
                        pathconfigexcelcopy = None
                        ):
        self.pathconf = pathconf
        self.pathconfigexcelcopy = pathconfigexcelcopy
        self.dicrowconf = returndictrowforcsv(path=pathconf)
        self.__fpath = fpath
        dirparhconf = parentdirectory(pathconf)
        self.__sheetnametor=self.dicrowconf["khns_sheetnamekhns"]
        self.__namefile=self.dicrowconf["khns_namfile"]
        self.__rangeg =self.dicrowconf["hm_rangege"]

        self.__rangeintct = returnseplistintbbystr(self.__rangeg)

        self.__rangestrct = returnliststr_from_str(self.__rangeg)

        self.__mvta = (self.dicrowconf["khns_mavatu"])
        self.__mvt = col2num (self.__mvta)
        self.__khns_ndcva = (self.dicrowconf["khns_noidungcongviec"])
        self.__khns_ndcv = col2num (self.__khns_ndcva)
        self.__khns_dvta = (self.dicrowconf["khns_dvt"])
        self.__khns_dvt = col2num (self.__khns_dvta)

        self.__khns_muchaophi = (self.dicrowconf["khns_muchaophi"])

        self.__khns_muchaophi_int = col2num(self.__khns_muchaophi)

        self.__hm_mvt = int(self.dicrowconf["hm_mvt"])
        self.__hm_ndcv = int(self.dicrowconf["hm_noidungcongviec"])
        self.__hm_dvt = int(self.dicrowconf["hm_dvt"])

        self.__hm_dgth_str = (self.dicrowconf["hm_dgth"])

        self.__hm_dgth = col2num(self.__hm_dgth_str)

        self.__hm_ttnt_str = (self.dicrowconf["hm_ttnt"])
        self.__hm_ttnt = col2num(self.__hm_ttnt_str)

        self.__hm_startrowvalue = int(self.dicrowconf["hm_startrowvalue"])
        self.__hm_vta = self.dicrowconf["hm_vt"]
        self.__hm_nca = self.dicrowconf["hm_nc"]
        self.__hm_mtca = self.dicrowconf["hm_mtc"]
        self.__hm_tha = self.dicrowconf["hm_th"]

        self.__hm_ct = self.dicrowconf["hm_ct"]
        self.__hm_ct_int = col2num(self.__hm_ct)

        self.__hm_vt =col2num (self.dicrowconf["hm_vt"]) 
        self.__hm_nc =col2num (self.dicrowconf["hm_nc"]) 
        self.__hm_mtc =col2num (self.dicrowconf["hm_mtc"])
        self.__hm_th =col2num (self.dicrowconf["hm_th"])
        self.__valuenotnone =self.dicrowconf["valuenotnone"]
        valueall =self.dicrowconf["valueall"]
        self.__dictvalue =self.dicrowconf["dictvalue"]
        # csv for dict 
        self.pathtovalue = refullpath(dirparhconf,self.__dictvalue)
        # csv for value 
        self.valuenotnone = refullpath(dirparhconf,self.__valuenotnone)
        # path all value 
        self.pathvalueall = refullpath(dirparhconf,valueall)

        self.__khns_rangenumbermct_ptvt =self.dicrowconf["khns_rangenumbermct_ptvt"]
        # hangmuccongtac 
        self.__hm_startpasterange = self.dicrowconf["hm_startpasterange"]
        self.__startpasterange = returnseplistintbbystr(self.__hm_startpasterange)
        self.__hm_congtac = self.dicrowconf["hm_congtac"]
        # add new##########################################################################33
        
        self.__khns_macongtac = self.dicrowconf["khns_macongtac"]
        self.__khns_noidungcongviec = self.dicrowconf["khns_noidungcongviec"]
        self.__khns_vattu = self.dicrowconf["khns_vattu"]
        self.__khns_nhancong = self.dicrowconf["khns_nhancong"]
        self.__khns_maytc = self.dicrowconf["khns_maytc"]
        
        self.__hm_th_formulas = self.dicrowconf["hm_th_formulas"]

        self.__khns_startrow = int(self.dicrowconf["khns_startrow"])
        # return list ma cong tac not node in cell value of ptvl by csv
        self.getvaluelist = convertcsvtolist(path=self.valuenotnone)
        # return all value from csv 
        self.getallvalue = convertcsvtolist(path=self.pathvalueall)

   
        self.pathlsn = refullpath(dirpath=getdirpath(pathconf),
                                        filename=self.dicrowconf["listsheetnamehm"])

        try:                        
            self.lsheetname = convertcsvto1list(path=self.pathlsn)
        except:
            pass
        self.__returnothervalue()
        self.__returnlistcongtac()