def upload(): try: file_handler = bottle.request.files.get('file') name, ext = os.path.splitext(file_handler.filename) if ext not in C.File_EXT: return C.ERROR_EXT fh = FileHelper() __filepath = fh.get_file_path(file_handler.filename) file_handler.save(__filepath) e_rw = ExcelRW() e_rw.get_result(__filepath) return C.SUCCESS_MESSAGE_BOTTLE.format(__filepath) except Exception as e: print(str(e))
def __set_sheet_data(self, ent, g86, p86, o86, g87, p87, o87): try: fh = FileHelper() filepath = fh.get_file_path(C.OUTPUT_FILE) self.file = filepath wb = self.__load_workbook() sheet = self.__get_sheet(wb, 'Pools') i = 7 for el in ent.EntityCode: sheet['A' + str(i)].value = el if el in ent.Name.keys(): sheet['B' + str(i)].value = ent.Name[el] # 86 General if el in g86.dic_Post_86_General_EP_959c3.keys(): sheet['D' + str(i)].value = g86.dic_Post_86_General_EP_959c3[el] else: sheet['D' + str(i)].value = 0 if el in g86.dic_Post_86_General_EP_959c2.keys(): sheet['E' + str(i)].value = g86.dic_Post_86_General_EP_959c2[el] else: sheet['E' + str(i)].value = 0 if el in g86.dic_Post_86_General_EP_959c1.keys(): sheet['F' + str(i)].value = g86.dic_Post_86_General_EP_959c1[el] else: sheet['F' + str(i)].value = 0 if el in g86.dic_Post_86_General_TAX_959c3Tax.keys(): sheet['G' + str( i)].value = g86.dic_Post_86_General_TAX_959c3Tax[el] else: sheet['G' + str(i)].value = 0 if el in g86.dic_Post_86_General_TAX_959c2Tax.keys(): sheet['H' + str( i)].value = g86.dic_Post_86_General_TAX_959c2Tax[el] else: sheet['H' + str(i)].value = 0 if el in g86.dic_Post_86_General_TAX_959c1Tax.keys(): sheet['I' + str( i)].value = g86.dic_Post_86_General_TAX_959c1Tax[el] else: sheet['I' + str(i)].value = 0 # 86 Passive if el in p86.dic_Post_86_Passive_EP_959c3.keys(): sheet['K' + str(i)].value = p86.dic_Post_86_Passive_EP_959c3[el] else: sheet['K' + str(i)].value = 0 if el in p86.dic_Post_86_Passive_EP_959c2.keys(): sheet['L' + str(i)].value = p86.dic_Post_86_Passive_EP_959c2[el] else: sheet['L' + str(i)].value = 0 if el in p86.dic_Post_86_Passive_EP_959c1.keys(): sheet['M' + str(i)].value = p86.dic_Post_86_Passive_EP_959c1[el] else: sheet['M' + str(i)].value = 0 if el in p86.dic_Post_86_Passive_TAX_959c3Tax.keys(): sheet['N' + str( i)].value = p86.dic_Post_86_Passive_TAX_959c3Tax[el] else: sheet['N' + str(i)].value = 0 if el in p86.dic_Post_86_Passive_TAX_959c2Tax.keys(): sheet['O' + str( i)].value = p86.dic_Post_86_Passive_TAX_959c2Tax[el] else: sheet['O' + str(i)].value = 0 if el in p86.dic_Post_86_Passive_TAX_959c1Tax.keys(): sheet['P' + str( i)].value = p86.dic_Post_86_Passive_TAX_959c1Tax[el] else: sheet['P' + str(i)].value = 0 # 86 Other if el in o86.dic_Post_86_Other_EP_959c3.keys(): sheet['R' + str(i)].value = o86.dic_Post_86_Other_EP_959c3[el] else: sheet['R' + str(i)].value = 0 if el in o86.dic_Post_86_Other_EP_959c2.keys(): sheet['S' + str(i)].value = o86.dic_Post_86_Other_EP_959c2[el] else: sheet['S' + str(i)].value = 0 if el in o86.dic_Post_86_Other_EP_959c1.keys(): sheet['T' + str(i)].value = o86.dic_Post_86_Other_EP_959c1[el] else: sheet['T' + str(i)].value = 0 if el in o86.dic_Post_86_Other_TAX_959c3Tax.keys(): sheet[ 'U' + str(i)].value = o86.dic_Post_86_Other_TAX_959c3Tax[el] else: sheet['U' + str(i)].value = 0 if el in o86.dic_Post_86_Other_TAX_959c2Tax.keys(): sheet[ 'V' + str(i)].value = o86.dic_Post_86_Other_TAX_959c2Tax[el] else: sheet['V' + str(i)].value = 0 if el in o86.dic_Post_86_Other_TAX_959c1Tax.keys(): sheet[ 'W' + str(i)].value = o86.dic_Post_86_Other_TAX_959c1Tax[el] else: sheet['W' + str(i)].value = 0 i += 1 #TODO: Save data for the next tab wb.save(self.file) except Exception as e: print(str(e))