from openpyxl import load_workbook ''' @File : @Author : william @Time : 2020/09/29 @notice : null @coding : utf-8 ''' # import xlrd # from xlutils.copy import copy import openpyxl # 下一步还得训练程序 # 使其满足对excel文件名和excel工作薄的识别 ws_fuzhaibiao_nianchucunhuo = 0 ws_fuzhaibiao_liudongzichanheji = 0 ws_fuzhaibiao_yingshouzhangkuan = 0 ws_fuzhaibiao_nianchucunhuo = 0 ws_fuzhaibiao_qimocunhuo = 0 ws_fuzhaibiao_gudingzichanyuanjia = 0 ws_fuzhaibiao_leijizhejiu = 0 ws_fuzhaibiao_bennianzhejiu = 0 ws_fuzhaibiao_zichanzongji = 0 ws_fuzhaibiao_fuzhaiheji = 0 ws_lirunbiao_yingyeshouru = 0 ws_lirunbiao_yingyechengben = 0 ws_lirunbiao_shuijinjifujia = 0 ws_lirunbiao_xiaoshoufeiyong = 0 ws_lirunbiao_guanlifeiyong = 0 ws_lirunbiao_yanfafeiyong = 0 ws_lirunbiao_caiwufeiyong = 0 ws_lirunbiao_lixishouru = 0 ws_lirunbiao_lixifeiyong = 0 ws_lirunbiao_guanlifeiyong = 0 ws_lirunbiao_yanfafeiyong = 0 ws_lirunbiao_caiwufeiyong = 0 ws_lirunbiao_lixishouru = 0 ws_lirunbiao_lixifeiyong = 0 ws_lirunbiao_yingyelirun = 0 ws_lirunbiao_yingyewaishouru = 0 ws_lirunbiao_yingyewaizhichu = 0 ws_lirunbiao_lirunzonge = 0 ws_lirunbiao_suodeshuifeiyong = 0 ws_nashuishenbaobiao_xiaoxiangshuie = 0 ws_nashuishenbaobiao_jinxiangshuie = 0 ws_nashuishenbaobiao_jinxiangshuiezhuanchu = 0 ws_nashuishenbaobiao_yingtuishuie = 0 ws_nashuishenbaobiao_yingnashuie = 0 ws_nashuishenbaobiao_yingbujiaoshuie = 0 ws_nashuishenbaobiao_yingnashuiejianzhenge = 0 nianchucunhuo_row = 0 nianchucunhuo_column = 0 liudongzichanheji_row = 0 liudongzichanheji_column = 0 yingshouzhangkuan_row = 0 yingshouzhangkuan_column = 0 qimocunhuo_row = 0 qimocunhuo_column = 0 gudingzichanyuanjia_row = 0 gudingzichanyuanjia_column = 0 leijizhejiu_row = 0 leijizhejiu_column = 0 bennianzhejiu_row = 0 bennianzhejiu_column = 0 zichanzongji_row = 0 zichanzongji_column = 0 fuzhaiheji_row = 0 fuzhaiheji_column = 0 fuzhaiheji_row_column = 0 yingyeshouru_row = 0 yingyeshouru_column = 0 yingyechengben_row = 0 yingyechengben_column = 0 shuijinjifujia_row = 0 shuijinjifujia_column = 0 xiaoshoufeiyong_row = 0 xiaoshoufeiyong_column = 0 guanlifeiyong_row = 0 guanlifeiyong_column = 0 yanfafeiyong_row = 0 yanfafeiyong_column = 0 caiwufeiyong_row = 0 caiwufeiyong_column = 0 lixishouru_row = 0 lixishouru_column = 0 lixifeiyong_row = 0 lixifeiyong_column = 0 yingyelirun_row = 0 yingyelirun_column = 0 yingyewaishouru_row = 0 yingyewaishouru_column = 0 yingyewaizhichu_row = 0 yingyewaizhichu_column = 0 lirunzonge_row = 0 lirunzonge_column = 0 suodeshuifeiyong_row = 0 suodeshuifeiyong_column = 0 yingjiaozengzhishui_row = 0 yingjiaozengzhishui_column = 0 pingjunrenshu_row = 0 pingjunrenshu_column = 0 xiaoxiangshuie_row = 0 xiaoxiangshuie_column = 0 jinxiangshuie_row = 0 jinxiangshuie_column = 0 jinxiangshuiezhuanchu_row = 0 jinxiangshuiezhuanchu_column = 0 yingtuishuie_row = 0 yingtuishuie_column = 0 yingnashuie_row = 0 yingnashuie_column = 0 yingbujiaoshuie_row = 0 yingbujiaoshuie_column = 0 yingnashuiejianzhenge_row = 0 yingnashuiejianzhenge_column = 0 fuzhaiheji_row = 0 fuzhaiheji_column = 0 #####################################################################锁定资产负债表和工作薄 # 如下代码用于多个相关表的打开操作 fn_fuzhaibiao = '资产负债表.xlsx' wb_fuzhaibiao = openpyxl.load_workbook(fn_fuzhaibiao) fuzhaibiao_allSheets = wb_fuzhaibiao.get_sheet_names() for i in range(len(fuzhaibiao_allSheets)): fuzhaibiao_sheet = wb_fuzhaibiao.get_sheet_by_name(fuzhaibiao_allSheets[i]) for row in fuzhaibiao_sheet.iter_rows(): for cell in row: if str(str(cell.value).replace(' ', '')).find("资产负债表") != -1: fuzhaibiao_sheet_selected = wb_fuzhaibiao.get_sheet_by_name(fuzhaibiao_allSheets[i]) break ws_fuzhaibiao = wb_fuzhaibiao.get_sheet_by_name(fuzhaibiao_sheet_selected.title) print(ws_fuzhaibiao) ##################################################锁定利润表和工作薄 fn_lirunbiao = '利润表.xlsx' wb_lirunbiao = openpyxl.load_workbook(fn_lirunbiao) lirunbiao_allSheets = wb_lirunbiao.get_sheet_names() for i in range(len(lirunbiao_allSheets)): lirunbiao_sheet = wb_lirunbiao.get_sheet_by_name(lirunbiao_allSheets[i]) for row in lirunbiao_sheet.iter_rows(): for cell in row: if str(str(cell.value).replace(' ', '')).find("利润表") != -1: lirunbiao_sheet_selected = wb_lirunbiao.get_sheet_by_name(lirunbiao_allSheets[i]) break ws_lirunbiao = wb_lirunbiao.get_sheet_by_name(lirunbiao_sheet_selected.title) ##############################################################################锁定财务表和工作薄 fn_caiwuzhuangkuangbiao = '财务状况表.xlsx' wb_caiwuzhuangkuangbiao = openpyxl.load_workbook(fn_caiwuzhuangkuangbiao) ws_caiwuzhuangkuangbiao = wb_caiwuzhuangkuangbiao.get_sheet_by_name("财务状况表") ################################################锁定纳税申报表和工作薄 fn_nashuishenbaobiao = '纳税申报表.xlsx' wb_nashuishenbaobiao = openpyxl.load_workbook(fn_nashuishenbaobiao) nashuishenbaobiao_allSheets = wb_nashuishenbaobiao.get_sheet_names() for i in range(len(nashuishenbaobiao_allSheets)): nashuishenbaobiao_sheet = wb_nashuishenbaobiao.get_sheet_by_name(nashuishenbaobiao_allSheets[i]) for row in nashuishenbaobiao_sheet.iter_rows(): for cell in row: if str(str(cell.value).replace(' ', '')).find("一般纳税人适用") != -1 or str(str(cell.value).replace(' ', '')).find("小规模纳税人适用") != -1: nashuishenbaobiao_sheet_selected = wb_nashuishenbaobiao.get_sheet_by_name( nashuishenbaobiao_allSheets[i]) break ws_nashuishenbaobiao = wb_nashuishenbaobiao.get_sheet_by_name(nashuishenbaobiao_sheet_selected.title) ############################################################### # 如下代码用于将多个表中的相关数据写入财务状况表 ########### 资产负债表 1年初存货 for row in ws_fuzhaibiao.iter_rows(): for cell in row: if str(str(cell.value).replace(' ', '')).find("存货") != -1: nianchucunhuo_row = cell.row else: ws_fuzhaibiao_nianchucunhuo = 0 break for row in ws_fuzhaibiao.iter_rows(): for cell in row: if str(str(cell.value).replace(' ', '')).find("年初余额") != -1 or str(str(cell.value).replace(' ', '')).find( "年初数") != -1: nianchucunhuo_column = cell.column break if nianchucunhuo_row == 0 or nianchucunhuo_column == 0: ws_fuzhaibiao_nianchucunhuo = 0 else: if ws_fuzhaibiao.cell(row=nianchucunhuo_row, column=nianchucunhuo_column).value != None: ws_fuzhaibiao_nianchucunhuo = round( float(str(ws_fuzhaibiao.cell(row=nianchucunhuo_row, column=nianchucunhuo_column).value).replace(',', '')) / 1000) ########### 资产负债表 2流动资产合计 for row in ws_fuzhaibiao.iter_rows(): for cell in row: # print(cell.value) if str(str(cell.value).replace(' ', '')).find("流动资产合计") != -1 and str(cell.value).find("非流动资产合计") == -1: liudongzichanheji_row = cell.row break for row in ws_fuzhaibiao.iter_rows(): for cell in row: if str(str(cell.value).replace(' ', '')).find("期末余额") != -1 or str(str(cell.value).replace(' ', '')).find( "期末数") != -1: liudongzichanheji_column = cell.column # print(zichanheji_column) break if liudongzichanheji_row == 0 or liudongzichanheji_column == 0: ws_fuzhaibiao_liudongzichanheji = 0 else: if ws_fuzhaibiao.cell(row=liudongzichanheji_row, column=liudongzichanheji_column).value != None: ws_fuzhaibiao_liudongzichanheji = round( float(str(ws_fuzhaibiao.cell(row=liudongzichanheji_row, column=liudongzichanheji_column).value).replace(',', '') )/ 1000) ########################################资产负债表 应收账款 for row in ws_fuzhaibiao.iter_rows(): for cell in row: if str(str(cell.value).replace(' ', '')).find("应收账款") != -1: yingshouzhangkuan_row = cell.row # print(zichanyuanjia_row) break for row in ws_fuzhaibiao.iter_rows(): for cell in row: if str(str(cell.value).replace(' ', '')).find("期末余额") != -1 or str(str(cell.value).replace(' ', '')).find( "期末数") != -1: yingshouzhangkuan_column = cell.column # print(zichanyuanjia_column) break if yingshouzhangkuan_row == 0 or yingshouzhangkuan_column == 0: ws_fuzhaibiao_yingshouzhangkuan = 0 else: if ws_fuzhaibiao.cell(row=yingshouzhangkuan_row, column=yingshouzhangkuan_column).value != None: ws_fuzhaibiao_yingshouzhangkuan = round(float(str( ws_fuzhaibiao.cell(row=yingshouzhangkuan_row, column=yingshouzhangkuan_column).value).replace(',', '')) / 1000) ################################ 资产负债表 4存货 for row in ws_fuzhaibiao.iter_rows(): for cell in row: if str(str(cell.value).replace(' ', '')).find("存货") != -1: qimocunhuo_row = cell.row # print(cunhuo_row) break for row in ws_fuzhaibiao.iter_rows(): for cell in row: if str(str(cell.value).replace(' ', '')).find("期末余额") != -1 or str(str(cell.value).replace(' ', '')).find( "期末数") != -1: qimocunhuo_column = cell.column # print(cunhuo_column) break if qimocunhuo_row == 0 or qimocunhuo_column == 0: ws_fuzhaibiao_qimocunhuo = 0 else: if ws_fuzhaibiao.cell(row=qimocunhuo_row, column=qimocunhuo_column).value != None: ws_fuzhaibiao_qimocunhuo = round(float(str(ws_fuzhaibiao.cell(row=qimocunhuo_row, column=qimocunhuo_column).value).replace(',', '')) / 1000) ########### 资产负债表 5固定资产原价 for row in ws_fuzhaibiao.iter_rows(): for cell in row: if str(str(cell.value).replace(' ', '')).find("固定资产原价") != -1: gudingzichanyuanjia_row = cell.row # print(zichanyuanjia_row) break for row in ws_fuzhaibiao.iter_rows(): for cell in row: if str(str(cell.value).replace(' ', '')).find("期末余额") != -1 or str(str(cell.value).replace(' ', '')).find( "期末数") != -1: gudingzichanyuanjia_column = cell.column # print(zichanyuanjia_column) break if gudingzichanyuanjia_row == 0 or gudingzichanyuanjia_column == 0: ws_fuzhaibiao_gudingzichanyuanjia = 0 else: if ws_fuzhaibiao.cell(row=gudingzichanyuanjia_row, column=gudingzichanyuanjia_column).value != None: ws_fuzhaibiao_gudingzichanyuanjia = round(float(str( ws_fuzhaibiao.cell(row=gudingzichanyuanjia_row, column=gudingzichanyuanjia_column) .value).replace(',', '')) / 1000) ########### 资产负债表 6累计折旧 for row in ws_fuzhaibiao.iter_rows(): for cell in row: if str(str(cell.value).replace(' ', '')).find("累计折旧") != -1: leijizhejiu_row = cell.row print(leijizhejiu_row) break for row in ws_fuzhaibiao.iter_rows(): for cell in row: if str(str(cell.value).replace(' ', '')).find("期末余额") != -1 or str(str(cell.value).replace(' ', '')).find( "期末数") != -1: leijizhejiu_column = cell.column print(leijizhejiu_column) break if leijizhejiu_row == 0 or leijizhejiu_column == 0: ws_fuzhaibiao_leijizhejiu = 0 print(ws_fuzhaibiao_leijizhejiu) else: if ws_fuzhaibiao.cell(row=leijizhejiu_row, column=leijizhejiu_column).value != None: ws_fuzhaibiao_leijizhejiu = round(float(str( ws_fuzhaibiao.cell(row=leijizhejiu_row, column=leijizhejiu_column).value).replace(',', '')) / 1000) #######################7本年折旧 ########### 资产负债表 8资产总计 for row in ws_fuzhaibiao.iter_rows(): for cell in row: if str(str(cell.value).replace(' ', '')).find("资产总计") != -1: zichanzongji_row = cell.row # print(zichanzongji_row) break for row in ws_fuzhaibiao.iter_rows(): for cell in row: if str(str(cell.value).replace(' ', '')).find("期末余额") != -1 or str(str(cell.value).replace(' ', '')).find( "期末数") != -1: zichanzongji_column = cell.column # print(zichanzongji_column) break if zichanzongji_row == 0 or zichanzongji_column == 0: ws_fuzhaibiao_zichanzongji = 0 else: if ws_fuzhaibiao.cell(row=zichanzongji_row, column=zichanzongji_column).value != None: ws_fuzhaibiao_zichanzongji = round(float(str( ws_fuzhaibiao.cell(row=zichanzongji_row, column=zichanzongji_column).value).replace(',', '')) / 1000) ########### 资产负债表 9负债合计 for row in ws_fuzhaibiao.iter_rows(): for cell in row: if str(str(cell.value).replace(' ', '')).find("负债合计") != -1 and str(cell.value).find("流动负债合计") == -1 and str( cell.value).find("非流动负债合计") == -1: fuzhaiheji_row = cell.row fuzhaiheji_row_column = cell.column break for row in ws_fuzhaibiao.iter_rows(): for cell in row: if str(str(cell.value).replace(' ', '')).find("期末余额") != -1 or str(str(cell.value).replace(' ', '')).find( "期末数") != -1: if cell.column > fuzhaiheji_row_column: fuzhaiheji_column = cell.column # print(fuzhaiheji_column) break if fuzhaiheji_row == 0 or fuzhaiheji_column == 0: ws_fuzhaibiao_hezhaiheji = 0 else: if ws_fuzhaibiao.cell(row=fuzhaiheji_row, column=fuzhaiheji_column).value != None: ws_fuzhaibiao_fuzhaiheji = round(float(str(ws_fuzhaibiao.cell(row=fuzhaiheji_row, column=fuzhaiheji_column).value).replace(',', '')) / 1000) ########### 利润表 10营业收入 for row in ws_lirunbiao.iter_rows(): for cell in row: # print(cell.value) if str(str(cell.value).replace(' ', '')).find("营业收入") != -1: yingyeshouru_row = cell.row # print(yingyeshouru_row) break for row in ws_lirunbiao.iter_rows(): # print(cell.value) for cell in row: if str(str(cell.value).replace(' ', '')).find("本年累计数") != -1 or str(str(cell.value).replace(' ', '')).find( "本年累计金额") != -1: yingyeshouru_column = cell.column # print(yingyeshouru_column) break if yingyeshouru_row == 0 or yingyeshouru_column == 0: ws_lirunbiao_yingyeshouru = 0 else: if ws_lirunbiao.cell(row=yingyeshouru_row, column=yingyeshouru_column).value != None: ws_lirunbiao_yingyeshouru = round(float(str( ws_lirunbiao.cell(row=yingyeshouru_row, column=yingyeshouru_column).value).replace(',', '')) / 1000) ########### 利润表 11营业成本 for row in ws_lirunbiao.iter_rows(): for cell in row: if str(str(cell.value).replace(' ', '')).find("营业成本") != -1: yingyechengben_row = cell.row # print(yingyechengben_row) break for row in ws_lirunbiao.iter_rows(): for cell in row: if str(str(cell.value).replace(' ', '')).find("本年累计数") != -1 or str(str(cell.value).replace(' ', '')).find( "本年累计金额") != -1: yingyechengben_column = cell.column # print(yingyechengben_column) break if yingyechengben_row == 0 or yingyechengben_column == 0: ws_lirunbiao_yingyechengben = 0 else: if ws_lirunbiao.cell(row=yingyechengben_row, column=yingyechengben_column).value != None: ws_lirunbiao_yingyechengben = round(float(str( ws_lirunbiao.cell(row=yingyechengben_row, column=yingyechengben_column).value).replace(',', '')) / 1000) ########### 利润表 12税金及附加 for row in ws_lirunbiao.iter_rows(): for cell in row: if str(str(cell.value).replace(' ', '')).find("税金及附加") != -1 or str(str(cell.value).replace(' ', '')).find( "主营业务税金及附加") == -1: shuijinjifujia_row = cell.row break for row in ws_lirunbiao.iter_rows(): for cell in row: if str(str(cell.value).replace(' ', '')).find("本年累计数") != -1 or str(str(cell.value).replace(' ', '')).find( "本年累计金额") != -1: shuijinjifujia_column = cell.column # print(fujia_column) break if shuijinjifujia_row == 0 or shuijinjifujia_column == 0: ws_lirunbiao_shuijinjifujia = 0 else: if ws_lirunbiao.cell(row=shuijinjifujia_row, column=shuijinjifujia_column).value != None: ws_lirunbiao_shuijinjifujia = round(float(str( ws_lirunbiao.cell(row=shuijinjifujia_row, column=shuijinjifujia_column).value).replace(',', '')) / 1000) ########### 利润表 13销售费用 for row in ws_lirunbiao.iter_rows(): for cell in row: if str(str(cell.value).replace(' ', '')).find("销售费用") != -1: xiaoshoufeiyong_row = cell.row # print(xiaoshoufeiyong_row) break for row in ws_lirunbiao.iter_rows(): for cell in row: if str(str(cell.value).replace(' ', '')).find("本年累计数") != -1 or str(str(cell.value).replace(' ', '')).find( "本年累计金额") != -1: xiaoshoufeiyong_column = cell.column # print(xiaoshoufeiyong_column) break if xiaoshoufeiyong_row == 0 or xiaoshoufeiyong_column == 0: ws_lirunbiao_xiaoshoufeiyong = 0 else: if ws_lirunbiao.cell(row=xiaoshoufeiyong_row, column=xiaoshoufeiyong_column).value != None: ws_lirunbiao_xiaoshoufeiyong = round(float(str( ws_lirunbiao.cell(row=xiaoshoufeiyong_row, column=xiaoshoufeiyong_column).value).replace(',', '')) / 1000) ########### 利润表 14管理费用 for row in ws_lirunbiao.iter_rows(): for cell in row: if str(str(cell.value).replace(' ', '')).find("管理费用") != -1: guanlifeiyong_row = cell.row # print(guanlifeiyong_row) break for row in ws_lirunbiao.iter_rows(): for cell in row: if str(str(cell.value).replace(' ', '')).find("本年累计数") != -1 or str(str(cell.value).replace(' ', '')).find( "本年累计金额") != -1: guanlifeiyong_column = cell.column # print(guanlifeiyong_column) break if guanlifeiyong_row == 0 or guanlifeiyong_column == 0: ws_lirunbiao_guanlifeiyong = 0 else: if ws_lirunbiao.cell(row=guanlifeiyong_row, column=guanlifeiyong_column).value != None: ws_lirunbiao_guanlifeiyong = round(float(str( ws_lirunbiao.cell(row=guanlifeiyong_row, column=guanlifeiyong_column).value).replace(',', '')) / 1000) ########### 利润表 15研发费用 研究费用? for row in ws_lirunbiao.iter_rows(): for cell in row: if str(str(cell.value).replace(' ', '')).find("研究费用") != -1 or str(str(cell.value).replace(' ', '')).find( "研发费用") != -1: yanfafeiyong_row = cell.row # print(yanfafeiyong_row) break for row in ws_lirunbiao.iter_rows(): for cell in row: if str(str(cell.value).replace(' ', '')).find("本年累计数") != -1 or str(str(cell.value).replace(' ', '')).find( "本年累计金额") != -1: yanfafeiyong_column = cell.column # print(yanfafeiyong_column) break if yanfafeiyong_row == 0 or yanfafeiyong_column == 0: ws_lirunbiao_yanfafeiyong = 0 else: if ws_lirunbiao.cell(row=yanfafeiyong_row, column=yanfafeiyong_column).value != None: ws_lirunbiao_yanfa = round(float(str( ws_lirunbiao.cell(row=yanfafeiyong_row, column=yanfafeiyong_column).value).replace(',', '')) / 1000) ########### 利润表 16财务费用 for row in ws_lirunbiao.iter_rows(): for cell in row: if str(str(cell.value).replace(' ', '')).find("财务费用") != -1: caiwufeiyong_row = cell.row # print(caiwufeiyong_row) break for row in ws_lirunbiao.iter_rows(): for cell in row: if str(str(cell.value).replace(' ', '')).find("本年累计数") != -1 or str(str(cell.value).replace(' ', '')).find( "本年累计金额") != -1: caiwufeiyong_column = cell.column # print(caiwufeiyong_column) break if caiwufeiyong_row == 0 or caiwufeiyong_column == 0: ws_lirunbiao_caiwufeiyong = 0 else: if ws_lirunbiao.cell(row=caiwufeiyong_row, column=caiwufeiyong_column).value != None: ws_lirunbiao_caiwufeiyong = round(float(str( ws_lirunbiao.cell(row=caiwufeiyong_row, column=caiwufeiyong_column).value).replace(',', '')) / 1000) ######################################################### 利润表 17利息收入 for row in ws_lirunbiao.iter_rows(): for cell in row: if str(str(cell.value).replace(' ', '')).find("利息费用") != -1: lixishouru_row = cell.row # print(caiwufeiyong_row) break for row in ws_lirunbiao.iter_rows(): for cell in row: if str(str(cell.value).replace(' ', '')).find("本年累计数") != -1 or str(str(cell.value).replace(' ', '')).find( "本年累计金额") != -1: lixishouru_column = cell.column # print(caiwufeiyong_column) break if lixishouru_row == 0 or lixishouru_column == 0: ws_lirunbiao_lixishouru = 0 else: if ws_lirunbiao.cell(row=lixishouru_row, column=lixishouru_column).value != None: if ws_lirunbiao.cell(row=lixishouru_row, column=lixishouru_column).value < 0: ws_lirunbiao_lixishouru = round(float(str( ws_lirunbiao.cell(row=lixishouru_row, column=lixishouru_column).value).replace(',', '')) / 1000) ################################################# 利润表 18利息费用 for row in ws_lirunbiao.iter_rows(): for cell in row: if str(str(cell.value).replace(' ', '')).find("利息费用") != -1: lixifeiyong_row = cell.row # print(caiwufeiyong_row) break for row in ws_lirunbiao.iter_rows(): for cell in row: if str(str(cell.value).replace(' ', '')).find("本年累计数") != -1 or str(str(cell.value).replace(' ', '')).find( "本年累计金额") != -1: lixifeiyong_column = cell.column # print(caiwufeiyong_column) break if lixifeiyong_row == 0 or lixifeiyong_column == 0: ws_lirunbiao_lixifeiyong = 0 else: if ws_lirunbiao.cell(row=lixifeiyong_row, column=lixifeiyong_column).value != None: if ws_lirunbiao.cell(row=lixifeiyong_row, column=lixifeiyong_column).value > 0: ws_lirunbiao_lixifeiyong = round(float(str( ws_lirunbiao.cell(row=lixifeiyong_row, column=lixifeiyong_column).value).replace(',', '')) / 1000) ########### 利润表 19营业利润 for row in ws_lirunbiao.iter_rows(): for cell in row: if str(str(cell.value).replace(' ', '')).find("营业利润") != -1: yingyelirun_row = cell.row # print(yingyelirun_row) break for row in ws_lirunbiao.iter_rows(): for cell in row: if str(str(cell.value).replace(' ', '')).find("本年累计数") != -1 or str(str(cell.value).replace(' ', '')).find( "本年累计金额") != -1: yingyelirun_column = cell.column # print(yingyelirun_column) break if yingyelirun_row == 0 or yingyelirun_column == 0: ws_lirunbiao_yingyelirun = 0 else: if ws_lirunbiao.cell(row=yingyelirun_row, column=yingyelirun_column).value != None: ws_lirunbiao_yingyelirun = round(float(str(ws_lirunbiao.cell(row=yingyelirun_row, column=yingyelirun_column).value).replace(',', '')) / 1000) ########### 利润表 20营业外收入 for row in ws_lirunbiao.iter_rows(): for cell in row: if str(str(cell.value).replace(' ', '')).find("营业外收入") != -1: yingyewaishouru_row = cell.row # print(yingyewaishouru_row) break for row in ws_lirunbiao.iter_rows(): for cell in row: if str(str(cell.value).replace(' ', '')).find("本年累计数") != -1 or str(str(cell.value).replace(' ', '')).find( "本年累计金额") != -1: yingyewaishouru_column = cell.column # print(yingyewaishouru_column) break if yingyewaishouru_row == 0 or yingyewaishouru_column == 0: ws_lirunbiao_yingyewaishouru = 0 else: if ws_lirunbiao.cell(row=yingyewaishouru_row, column=yingyewaishouru_column).value != None: ws_lirunbiao_yingyewaishouru = round(float(str( ws_lirunbiao.cell(row=yingyewaishouru_row, column=yingyewaishouru_column).value).replace(',', '')) / 1000) ########### 利润表 营业外支出 for row in ws_lirunbiao.iter_rows(): for cell in row: if str(str(cell.value).replace(' ', '')).find("营业外支出") != -1: yingyewaizhichu_row = cell.row # print(yingyewaizhichu_row) break for row in ws_lirunbiao.iter_rows(): for cell in row: if str(str(cell.value).replace(' ', '')).find("本年累计数") != -1 or str(str(cell.value).replace(' ', '')).find( "本年累计金额") != -1: yingyewaizhichu_column = cell.column # print(yingyewaizhichu_column) break if yingyewaizhichu_row == 0 or yingyewaizhichu_column == 0: ws_lirunbiao_yingyewaizhichu = 0 else: if ws_lirunbiao.cell(row=yingyewaizhichu_row, column=yingyewaizhichu_column).value != None: #print(type( ws_lirunbiao.cell(row=yingyewaizhichu_row, column=yingyewaizhichu_column).value)) ws_lirunbiao_yingyewaizhichu = round(float(str( ws_lirunbiao.cell(row=yingyewaizhichu_row, column=yingyewaizhichu_column).value).replace(',', '')) / 1000) ########### 利润表 22利润总额 for row in ws_lirunbiao.iter_rows(): for cell in row: if str(str(cell.value).replace(' ', '')).find("利润总额") != -1: lirunzonge_row = cell.row print("**********") print(lirunzonge_row) break for row in ws_lirunbiao.iter_rows(): for cell in row: if str(str(cell.value).replace(' ', '')).find("本年累计数") != -1 or str(str(cell.value).replace(' ', '')).find( "本年累计金额") != -1: lirunzonge_column = cell.column print(lirunzonge_column) break if lirunzonge_row == 0 or lirunzonge_column == 0: ws_lirunbiao_lirunzonge = 0 else: if ws_lirunbiao.cell(row=lirunzonge_row, column=lirunzonge_column).value != None: ws_lirunbiao_lirunzonge = round(float(str(ws_lirunbiao.cell(row=lirunzonge_row,column=lirunzonge_column).value).replace(',', '')) / 1000) ########### 利润表 23所得税费用 for row in ws_lirunbiao.iter_rows(): for cell in row: if str(str(cell.value).replace(' ', '')).find("所得税费用") != -1: suodeshuifeiyong_row = cell.row # print(suodeshuifeiyong_row) break for row in ws_lirunbiao.iter_rows(): for cell in row: if str(str(cell.value).replace(' ', '')).find("本年累计数") != -1 or str(str(cell.value).replace(' ', '')).find( "本年累计金额") != -1: suodeshuifeiyong_column = cell.column # print(suodeshuifeiyong_column) break if suodeshuifeiyong_row == 0 or suodeshuifeiyong_column == 0: ws_lirunbiao_suodeshuifeiyong = 0 else: if ws_lirunbiao.cell(row=suodeshuifeiyong_row, column=suodeshuifeiyong_column).value != None: ws_lirunbiao_suodeshuifeiyong = round(float(str( ws_lirunbiao.cell(row=suodeshuifeiyong_row, column=suodeshuifeiyong_column).value).replace(',', '')) / 1000) ########### 纳税申报表 应交增值税 ##############纳税申报表 应交增值税 24.1 销项税额 for row in ws_nashuishenbaobiao.iter_rows(): for cell in row: if str(str(cell.value).replace(' ', '')).find("销项税额") != -1: xiaoxiangshuie_row = cell.row print(xiaoxiangshuie_row) # print(xiaoxiangshuie_row) break for row in ws_nashuishenbaobiao.iter_rows(): for cell in row: if str(str(cell.value).replace(' ', '')).find("本年累计") != -1 or str(str(cell.value).replace(' ', '')).find( "累计金额") != -1: xiaoxiangshuie_column = cell.column # print(xiaoxiangshuie_column) break if xiaoxiangshuie_row == 0 or xiaoxiangshuie_column == 0: ws_nashuishenbaobiao_xiaoxiangshuie = 0 else: if ws_nashuishenbaobiao.cell(row=xiaoxiangshuie_row, column=xiaoxiangshuie_column).value != None: ws_nashuishenbaobiao_xiaoxiangshuie = round(float(str( ws_nashuishenbaobiao.cell(row=xiaoxiangshuie_row, column=xiaoxiangshuie_column).value).replace(',', '')) / 1000) ##############纳税申报表 应交增值税 24.2进项税额 for row in ws_nashuishenbaobiao.iter_rows(): for cell in row: if str(str(cell.value).replace(' ', '')).find("进项税额") != -1 and str(str(cell.value).replace(' ', '')).find( "进项税额转出") == -1: jinxiangshuie_row = cell.row # print(jinxiangshuie_row) break for row in ws_nashuishenbaobiao.iter_rows(): for cell in row: if str(str(cell.value).replace(' ', '')).find("本年累计") != -1 or str(str(cell.value).replace(' ', '')).find( "累计金额") != -1: jinxiangshuie_column = cell.column # print(jinxiangshuie_column) break if jinxiangshuie_row == 0 or jinxiangshuie_column == 0: ws_nashuishenbaobiao_jinxiangshuie = 0 else: if ws_nashuishenbaobiao.cell(row=jinxiangshuie_row, column=jinxiangshuie_column).value != None: ws_nashuishenbaobiao_jinxiangshuie = round(float(str( ws_nashuishenbaobiao.cell(row=jinxiangshuie_row, column=jinxiangshuie_column).value).replace(',', '')) / 1000) ##############纳税申报表 应交增值税 24.3进项税额转出 for row in ws_nashuishenbaobiao.iter_rows(): for cell in row: if str(str(cell.value).replace(' ', '')).find("进项税额转出") != -1: jinxiangshuiezhuanchu_row = cell.row # print(jinxiangshuiezhuanchu_row) break for row in ws_nashuishenbaobiao.iter_rows(): for cell in row: if str(str(cell.value).replace(' ', '')).find("本年累计") != -1 or str(str(cell.value).replace(' ', '')).find( "累计金额") != -1: jinxiangshuiezhuanchu_column = cell.column # print(jinxiangshuiezhuanchu_column) break if jinxiangshuiezhuanchu_row == 0 or jinxiangshuiezhuanchu_column == 0: ws_nashuishenbaobiao_jinxiangshuiezhuanchu = 0 else: if ws_nashuishenbaobiao.cell(row=jinxiangshuiezhuanchu_row, column=jinxiangshuiezhuanchu_column).value != None: ws_nashuishenbaobiao_jinxiangshuiezhuanchu =round(float(str( ws_nashuishenbaobiao.cell(row=jinxiangshuiezhuanchu_row, column=jinxiangshuiezhuanchu_column).value).replace(',', '')) / 1000) ##############纳税申报表 应交增值税 24.4免、抵、退应退税额 for row in ws_nashuishenbaobiao.iter_rows(): for cell in row: if str(str(cell.value).replace(' ', '')).find("免、抵、退应退税额") != -1: yingtuishuie_row = cell.row # print(yingtuishuie_row) break for row in ws_nashuishenbaobiao.iter_rows(): for cell in row: if str(str(cell.value).replace(' ', '')).find("本年累计") != -1 or str(str(cell.value).replace(' ', '')).find( "累计金额") != -1: yingtuishuie_column = cell.column # print(yingtuishuie_column) break if yingtuishuie_row == 0 or yingtuishuie_column == 0: ws_nashuishenbaobiao_yingtuishuie = 0 else: if ws_nashuishenbaobiao.cell(row=yingtuishuie_row, column=yingtuishuie_column).value != None: ws_nashuishenbaobiao_yingtuishuie = round(float(str( ws_nashuishenbaobiao.cell(row=yingtuishuie_row, column=yingtuishuie_column).value).replace(',', '')) / 1000) ##############纳税申报表 应交增值税 24.5简易计税办法计算的应纳税额 for row in ws_nashuishenbaobiao.iter_rows(): for cell in row: if str(str(cell.value).replace(' ', '')).find("简易计税办法计算的应纳税额") != -1: yingnashuie_row = cell.row # print(yingnashuie_row) break for row in ws_nashuishenbaobiao.iter_rows(): for cell in row: if str(str(cell.value).replace(' ', '')).find("本年累计") != -1 or str(str(cell.value).replace(' ', '')).find( "累计金额") != -1: yingnashuie_column = cell.column # print(yingnashuie_column) break if yingnashuie_row == 0 or yingnashuie_column == 0: ws_nashuishenbaobiao_yingnashuie = 0 else: if ws_nashuishenbaobiao.cell(row=yingnashuie_row, column=yingnashuie_column).value != None: ws_nashuishenbaobiao_yingnashuie = round(float(str( ws_nashuishenbaobiao.cell(row=yingnashuie_row, column=yingnashuie_column).value).replace(',', '')) / 1000) ##############纳税申报表 应交增值税 24.6按简易计税办法计算的纳税检查应补缴税额 for row in ws_nashuishenbaobiao.iter_rows(): for cell in row: if str(str(cell.value).replace(' ', '')).find("按简易计税办法计算的纳税检查应补缴税额") != -1: yingbujiaoshuie_row = cell.row # print(yingbujiaoshuie_row) break for row in ws_nashuishenbaobiao.iter_rows(): for cell in row: if str(str(cell.value).replace(' ', '')).find("本年累计") != -1 or str(str(cell.value).replace(' ', '')).find( "累计金额") != -1: yingbujiaoshuie_column = cell.column # print(yingbujiaoshuie_column) break if yingbujiaoshuie_row == 0 or yingbujiaoshuie_column == 0: ws_nashuishenbaobiao_yingbujiaoshuie = 0 else: if ws_nashuishenbaobiao.cell(row=yingbujiaoshuie_row, column=yingbujiaoshuie_column).value != None: ws_nashuishenbaobiao_yingbujiaoshuie = round(float(str( ws_nashuishenbaobiao.cell(row=yingbujiaoshuie_row, column=yingbujiaoshuie_column).value).replace(',', '')) / 1000) # print(ws_nashuishenbaobiao_Z31) ##############纳税申报表 应交增值税 24.7应纳税额减征额 for row in ws_nashuishenbaobiao.iter_rows(): for cell in row: if str(str(cell.value).replace(' ', '')).find("应纳税额减征额") != -1: yingnashuiejianzhenge_row = cell.row # print(yingnashuiejianzhenge_row) break for row in ws_nashuishenbaobiao.iter_rows(): for cell in row: if str(str(cell.value).replace(' ', '')).find("本年累计") != -1 or str(str(cell.value).replace(' ', '')).find( "累计金额") != -1: yingnashuiejianzhenge_column = cell.column # print(yingnashuiejianzhenge_column) break if yingnashuiejianzhenge_row == 0 or yingnashuiejianzhenge_column == 0: ws_nashuishenbaobiao_yingnashuiejianzhenge = 0 else: if ws_nashuishenbaobiao.cell(row=yingnashuiejianzhenge_row, column=yingnashuiejianzhenge_column).value != None: ws_nashuishenbaobiao_yingnashuiejianzhenge = round(float(str( ws_nashuishenbaobiao.cell(row=yingnashuiejianzhenge_row, column=yingnashuiejianzhenge_column).value).replace(',', '')) / 1000) # print(ws_nashuishenbaobiao_Z32) ws_caiwuzhuangkuangbiao['E3'] = ws_fuzhaibiao_nianchucunhuo ws_caiwuzhuangkuangbiao['E5'] = ws_fuzhaibiao_liudongzichanheji ws_caiwuzhuangkuangbiao['E6'] = ws_fuzhaibiao_yingshouzhangkuan ws_caiwuzhuangkuangbiao['E7'] = ws_fuzhaibiao_qimocunhuo ws_caiwuzhuangkuangbiao['E8'] = ws_fuzhaibiao_gudingzichanyuanjia ws_caiwuzhuangkuangbiao['E9'] = ws_fuzhaibiao_leijizhejiu ws_caiwuzhuangkuangbiao['E10'] = ws_fuzhaibiao_bennianzhejiu ws_caiwuzhuangkuangbiao['E11'] = ws_fuzhaibiao_zichanzongji ws_caiwuzhuangkuangbiao['E12'] = ws_fuzhaibiao_fuzhaiheji ws_caiwuzhuangkuangbiao['E14'] = ws_lirunbiao_yingyeshouru ws_caiwuzhuangkuangbiao['E15'] = ws_lirunbiao_yingyechengben ws_caiwuzhuangkuangbiao['E16'] = ws_lirunbiao_shuijinjifujia ws_caiwuzhuangkuangbiao['E17'] = ws_lirunbiao_xiaoshoufeiyong ws_caiwuzhuangkuangbiao['E18'] = ws_lirunbiao_guanlifeiyong ws_caiwuzhuangkuangbiao['E19'] = ws_lirunbiao_yanfafeiyong ws_caiwuzhuangkuangbiao['E20'] = ws_lirunbiao_caiwufeiyong ws_caiwuzhuangkuangbiao['E21'] = ws_lirunbiao_lixishouru ws_caiwuzhuangkuangbiao['E22'] = ws_lirunbiao_lixifeiyong ws_caiwuzhuangkuangbiao['E23'] = ws_lirunbiao_yingyelirun ws_caiwuzhuangkuangbiao['E24'] = ws_lirunbiao_yingyewaishouru ws_caiwuzhuangkuangbiao['E25'] = ws_lirunbiao_yingyewaizhichu ws_caiwuzhuangkuangbiao['E26'] = ws_lirunbiao_lirunzonge ws_caiwuzhuangkuangbiao['E27'] = ws_lirunbiao_suodeshuifeiyong # 如下代码用于将多个表中的相关数据写入财务状况表------特例:利润表中利息费用指标,如果为正计财务状况表的利息收入,如果为负数计财务状况表的利息费用 # print(ws_lirunbiao_C22) ws_caiwuzhuangkuangbiao['E28'] = ws_nashuishenbaobiao_xiaoxiangshuie - ( ws_nashuishenbaobiao_jinxiangshuie - ws_nashuishenbaobiao_jinxiangshuiezhuanchu - ws_nashuishenbaobiao_yingtuishuie) + ws_nashuishenbaobiao_yingnashuie + ws_nashuishenbaobiao_yingbujiaoshuie - ws_nashuishenbaobiao_yingnashuiejianzhenge # 保存财务状况表中修改的数据 wb_caiwuzhuangkuangbiao.save('财务状况表.xlsx')
一键式统计表3.0季报_错误在else
猜你喜欢
转载自blog.csdn.net/jidawanghao/article/details/112274858
今日推荐
周排行