一键式统计6.0通透
#coding:utf-8 # import os import win32com.client as win32 import shutil import openpyxl import os import win32com.client as win32 import shutil import openpyxlimport timeimport time#####part onefn = {'资产负债表':0,'利润表':0,'纳税申报表':0,'财务状况表':0 } ws = {'资产负债表':0,'利润表':0,'纳税申报表':0,'财务状况表':0 }mydir = 'bak' #基本逻辑就是分两种情况,文件夹有和无,有时,为了避免里面数据污染,删了重建一个;没有则是正常建一个就好if os.path.exists(mydir) == 0 :os.mkdir(mydir) else:shutil.rmtree('bak')os.mkdir(mydir)file = []path = os.getcwd() # 转换前程序所在文件目录path_bak = os.getcwd() + r'/bak/'pathdir = os.listdir(path) #print(pathdir) for s in pathdir:newdir = os.path.join(path, s)if os.path.isfile(newdir):os.chdir(path_bak)pathdir_bak = os.listdir(path_bak)# print(pathdir_bak)if os.path.splitext(newdir)[1] == ".xls":t = os.path.split(s)[1] + r'x'if os.path.exists(t):# print(os.path.exists(os.path.split(s)[1]))breakelse:excel = win32.gencache.EnsureDispatch('Excel.Application')wb = excel.Workbooks.Open(newdir)# print(newdir)path_dir = os.path.split(newdir)[0]path_file = os.path.split(newdir)[1]# print(path_dir)# print(path_file)wb.SaveAs(path_dir + '/bak/' + path_file + 'x', FileFormat=51) # FileFormat = 51 is for .xlsx extensionwb.Close() # FileFormat = 56 is for .xls extensionexcel.Application.Quit()elif os.path.splitext(newdir)[1] == ".xlsx":file.append(newdir)elif os.path.isdir(newdir):continuefor i in range(len(file)):pcm_file = file[i]path_0 = os.path.split(file[i])[0]path_1 = os.path.split(file[i])[1]oldname = path_0 + '/' + path_1newname = path_0 + r'/bak/' + path_1shutil.copyfile(oldname, newname)#time.sleep(5) #暂停10秒#####第二步将文件目录切换至bak文件夹中,,切片u v wfile_deal = []path_deal = os.getcwd() # 转换前程序所在文件目录pathdir_deal = os.listdir(path_deal) for u in pathdir_bak:newdir_deal = os.path.join(path_deal, u)file_deal.append(newdir_deal)# print(file_deal)for j in range(len(file_deal)):pcm_file_deal = file_deal[j]path_0_deal = os.path.split(file_deal[j])[0] #文件所在目录path_1_deal = os.path.split(file_deal[j])[1] #文件名称带后缀# print(pcm_file_deal)# print(path_0_deal)#print(path_1_deal)wb = openpyxl.load_workbook(path_1_deal)allSheets = wb.get_sheet_names()for i in range(len(allSheets)):sheet = wb.get_sheet_by_name(allSheets[i])for row in sheet.iter_rows():for cell in row:if str(str(cell.value).replace(' ', '')).find("资产负债表") != -1:sheet_selected = wb.get_sheet_by_name(allSheets[i])#print(sheet_selected)#print(path_1_deal)fn['资产负债表'] = path_1_deal#print(fn_fuzhaibiao)ws['资产负债表'] = wb.get_sheet_by_name(sheet_selected.title)#print(type(ws['资产负债表']))continueelif str(str(cell.value).replace(' ', '')).find("利润表") != -1 or str(str(cell.value).replace(' ', '')).find("损益表") != -1:sheet_selected = wb.get_sheet_by_name(allSheets[i])#print(sheet_selected)#print(path_1_deal)fn['利润表'] = path_1_dealws['利润表'] = wb.get_sheet_by_name(sheet_selected.title)continueelif str(str(cell.value).replace(' ', '')).find("一般纳税人适用") != -1 or str(str(cell.value).replace(' ', '')).find("小规模纳税人适用") != -1:sheet_selected = wb.get_sheet_by_name(allSheets[i])#print(sheet_selected)#print(path_1_deal)fn['纳税申报表'] = path_1_dealprint(path_1_deal)ws['纳税申报表'] = wb.get_sheet_by_name(sheet_selected.title)continueelif str(str(cell.value).replace(' ', '')).find("***子表开始") != -1:sheet_selected = wb.get_sheet_by_name(allSheets[i])#print(sheet_selected)#print(path_1_deal)fn['财务状况表'] = path_1_deal#print(fn_fuzhaibiao)ws['财务状况表'] = wb.get_sheet_by_name(sheet_selected.title)#print(type(ws['资产负债表']))continue################part twodef getdate(ws_source,date_row, date_column):row_result = 0column_result = 0result = 0for row in ws_source.iter_rows():for cell in row:for i in range(len(date_row)):#print(cell.value)#print(date_row[i])#print(str(str(cell.value).replace(' ', '')).find(date_row[i]))#print(cell.value)#print(len(str(cell.value).replace(' ', '')))#print(len(str(cell.value).replace(' ', '')))#print(len(date_row[i]))if str(str(cell.value).replace(' ', '')).find(date_row[i]) != -1 :#print(len(str(cell.value).replace(' ', '')))#print(len(date_row[i]))#print(str(str(cell.value).replace(' ', '')).find(date_row[i]))row_result = cell.rowcolumn_result = cell.column + 3#print(cell.value)#print(cell.row)#print(row_result)breakif row_result == 0 or column_result == 0:result = 0else:if ws_source.cell(row = row_result , column = column_result).value != None:#print(ws_source.cell(row=row_result, column=column_result).value)result = ws_source.cell(row=row_result, column=column_result).valuereturn resultdef writedate(ws_source,date_row, date_column,data_write):row_result = 0column_result = 0result = 0for row in ws_source.iter_rows():for cell in row:for i in range(len(date_row)):if str(str(cell.value).replace(' ', '')).find(date_row[i]) != -1 :row_result = cell.rowcolumn_result = cell.column + 3print(column_result)breakws_source.cell(row=row_result, column=column_result).value = data_writewb.save(fn['财务状况表'])##############################part three if __name__ == '__main__':# 资产负债表print(getdate(ws['资产负债表'], ['存货'], ['年初余额', '年初数']));print(getdate(ws['资产负债表'],['流动资产合计'],['期末余额','期末数']));print(getdate(ws['资产负债表'],['应收账款'],['期末余额','期末数']));print(getdate(ws['资产负债表'],['固定资产原价'],['期末余额','期末数']));print(getdate(ws['资产负债表'],['累计折旧'],['期末余额','期末数']));print(getdate(ws['资产负债表'],['资产总计'],['期末余额','期末数']));print(getdate(ws['资产负债表'],['负债合计'],['期末余额','期末数']));#利润表print(getdate(ws['利润表'],['营业收入'],['本年累计数','本年累计金额']));print(getdate(ws['利润表'],['营业成本'],['本年累计数','本年累计金额']));print(getdate(ws['利润表'],['税金及附加'],['本年累计数','本年累计金额']));print(getdate(ws['利润表'],['销售费用'],['本年累计数','本年累计金额']));print(getdate(ws['利润表'],['管理费用'],['本年累计数','本年累计金额']));print(getdate(ws['利润表'],['研究费用','研发费用'],['本年累计数','本年累计金额']));print(getdate(ws['利润表'],['财务费用'],['本年累计数','本年累计金额']));print(getdate(ws['利润表'],['利息费用'],['本年累计数','本年累计金额'])); ####这个地方有问题,需要更改下,正负不同区别为利息收入、利息费用#############利息收入print(getdate(ws['利润表'],['营业利润'],['本年累计数','本年累计金额']));print(getdate(ws['利润表'],['营业外收入'],['本年累计数','本年累计金额']));print(getdate(ws['利润表'],['营业外支出'],['本年累计数','本年累计金额']));print(getdate(ws['利润表'],['利润总额'],['本年累计数','本年累计金额']));print(getdate(ws['利润表'],['所得税费用'],['本年累计数','本年累计金额']));#纳税申报表print(getdate(ws['纳税申报表'],['销项税额'],['本年累计','累计金额']));print(getdate(ws['纳税申报表'],['进项税额'],['本年累计','累计金额']));print(getdate(ws['纳税申报表'],['进项税额转出'],['本年累计','累计金额']));print(getdate(ws['纳税申报表'],['免、抵、退应退税额'],['本年累计','累计金额']));print(getdate(ws['纳税申报表'],['简易计税办法计算的应纳税额'],['本年累计','累计金额']));print(getdate(ws['纳税申报表'],['按简易计税办法计算的纳税检查应补缴税款'],['本年累计','累计金额']));print(getdate(ws['纳税申报表'],['应纳税额减征额'],['本年累计','累计金额']));###写入操作#年初存货writedate(ws['财务状况表'],['年初存货'],['1-本季'],getdate(ws['资产负债表'], ['存货'], ['年初余额', '年初数']))#流动资产合计writedate(ws['财务状况表'],['流动资产合计'],['1-本季'],getdate(ws['资产负债表'],['流动资产合计'],['期末余额','期末数']))#应收账款writedate(ws['财务状况表'],['应收账款'],['1-本季'],getdate(ws['资产负债表'],['应收账款'],['期末余额','期末数']))#存货 ---期末数writedate(ws['财务状况表'],['存货'],['1-本季'],getdate(ws['资产负债表'],['存货'],['期末余额','期末数']))#固定资产原价writedate(ws['财务状况表'],['固定资产原价'],['1-本季'],getdate(ws['资产负债表'],['固定资产原价'],['期末余额','期末数']))#累计折旧writedate(ws['财务状况表'],['累计折旧'],['1-本季'],getdate(ws['资产负债表'],['累计折旧'],['期末余额','期末数']))#本年折旧#资产总计writedate(ws['财务状况表'],['资产总计'],['1-本季'],getdate(ws['资产负债表'],['资产总计'],['期末余额','期末数']))#负债合计writedate(ws['财务状况表'],['负债合计'],['1-本季'],getdate(ws['资产负债表'],['负债合计'],['期末余额','期末数']))#营业收入writedate(ws['财务状况表'],['营业收入'],['1-本季'],getdate(ws['利润表'],['营业收入'],['本年累计数','本年累计金额']))#营业成本writedate(ws['财务状况表'],['营业成本'],['1-本季'],getdate(ws['利润表'],['营业成本'],['本年累计数','本年累计金额']))#税金及附加writedate(ws['财务状况表'],['税金及附加'],['1-本季'],getdate(ws['利润表'],['税金及附加'],['本年累计数','本年累计金额']))#销售费用writedate(ws['财务状况表'],['销售费用'],['1-本季'],getdate(ws['利润表'],['销售费用'],['本年累计数','本年累计金额']))#管理费用writedate(ws['财务状况表'],['管理费用'],['1-本季'],getdate(ws['利润表'],['管理费用'],['本年累计数','本年累计金额']))#研发费用writedate(ws['财务状况表'],['研发费用'],['1-本季'],getdate(ws['利润表'],['研究费用','研发费用'],['本年累计数','本年累计金额']))#财务费用writedate(ws['财务状况表'],['财务费用'],['1-本季'],getdate(ws['利润表'],['财务费用'],['本年累计数','本年累计金额']))#利息收入writedate(ws['财务状况表'],['利息收入'],['1-本季'],getdate(ws['利润表'],['利息费用'],['本年累计数','本年累计金额']))#利息费用writedate(ws['财务状况表'],['利息费用'],['1-本季'],getdate(ws['利润表'],['利息费用'],['本年累计数','本年累计金额']))#营业利润writedate(ws['财务状况表'],['营业利润'],['1-本季'],getdate(ws['利润表'],['营业利润'],['本年累计数','本年累计金额']))#营业外收入writedate(ws['财务状况表'],['营业外收入'],['1-本季'],getdate(ws['利润表'],['营业外收入'],['本年累计数','本年累计金额']))#营业外支出writedate(ws['财务状况表'],['营业外支出'],['1-本季'],getdate(ws['利润表'],['营业外支出'],['本年累计数','本年累计金额']))#利润总额writedate(ws['财务状况表'],['利润总额'],['1-本季'],getdate(ws['利润表'],['利润总额'],['本年累计数','本年累计金额']))#所得税费用writedate(ws['财务状况表'],['所得税费用'],['1-本季'],getdate(ws['利润表'],['所得税费用'],['本年累计数','本年累计金额']))#应交增值税= 销项税额 -(进项税额 - 进项税额转出 - 免、抵、退应退税额)+ 简易计税办法计算的应纳税额 + 按简易计税办法计算的纳税检查应补缴税额 - 应征税额减征额writedate(ws['财务状况表'], ['应交增值税'], ['1-本季'], getdate(ws['纳税申报表'], ['销项税额'], ['本年累计', '累计金额']) - ( getdate(ws['纳税申报表'], ['进项税额'], ['本年累计', '累计金额']) - getdate(ws['纳税申报表'], ['进项税额转出'],['本年累计', '累计金额']) - getdate(ws['纳税申报表'],['简易计税办法计算的应纳税额'], ['本年累计', '累计金额'])) + getdate(ws['纳税申报表'], ['按简易计税办法计算的纳税检查应补缴税额'],['本年累计', '累计金额']) - getdate(ws['纳税申报表'],['应征税额减征额'],['本年累计', '累计金额']))#从事批发和零售业活动的从业人员平均人数
一键式统计6.0通透相关推荐
- 一键式统计8.0操作使用手册
一键式统计使用手册 在电脑桌面,或各硬盘分区下,或某个文件夹中,新建一个空白的文件夹,然后将"一键式统计报表生成软件.exe"程序拷贝至此文件夹中. 然后,将纳税申报表.利润表.资 ...
- 一键式统计6.0季报测试
#coding:utf-8 # import os import win32com.client as win32 import shutil import openpyxl import os im ...
- 一键式统计5.0基本搞定
import os import win32com.client as win32 import shutil import openpyxl import os import win32com.cl ...
- 一键式统计5.0待完善
import os import win32com.client as win32 import shutil import openpyxl import os import win32com.cl ...
- 会计税务一键式统计2.0_按照内容锁定动态锁定工作薄,待更新
from openpyxl import load_workbook''' @File : @Author : william @Time : 2020/09/29 @notice : null @c ...
- 深度解读志拓智慧厕所系统方案(干货合集,一文通透了解智慧厕所) 智慧公厕|智慧城市
深度解读志拓智慧厕所系统方案 (干货合集,一文通透了解志拓智慧厕所)智慧厕所|智慧厕所引导系统|智慧公厕|环境监测 智慧厕所管理系统有两大组成部分 软件 和 硬件. 细分下来有六个系统: 智慧厕所厕位 ...
- PCA/PCC软件中一键式超高密度的无人机LiDAR点云滤波和精细地形提取
激光雷达是一种方兴未艾的测量技术.基于搭载平台类型,可以细分为星载.机载.地面.车载.背包.船载LiDAR等.其中,机载LiDAR测量技术较为常见,主要用于获取被测量区域的高精度.高分辨率的数字高程模 ...
- airpodspro窃听模式_AirPods pro通透模式什么原理?
AirPods Pro的通透模式也就是我们所常说的环境音模式,环境音模式就是设备在保证低频降噪的效果下,同时开启人声的增益.让通话更清晰更流畅.在与人面对面交流时,无需摘下耳机,切换至环境音模式即可. ...
- 一文通透从输入URL到页面渲染的全过程----高频面试
一文通透从输入URL到页面渲染的全过程----高频面试 喜欢大海 喜欢夕阳 写下便是永恒 文章目录 一文通透从输入URL到页面渲染的全过程----高频面试 重温 进程与线程 什么是进程 什么是线程 进 ...
最新文章
- 7.Java中变量的隐式转换以及强类型转换
- oracle和mysql的安装教程_客户端安装和配置(1) - Oracle 10g 安装图解教程_数据库技术_Linux公社-Linux系统门户网站...
- c语言分配内存空间方法,C语言之动态分配内存空间
- 计算机硬件外围设备介绍,天津2012年自考“计算机外围设备使用与维护”课程考试大纲...
- how many fibs java_How many Fibs?(java)
- SCOM2012部署系列之十三:监控Exchange server 2013 RTM
- ubuntu18.04安装unity tweak tool
- AI技术人才成长路线十大方向
- android空格对齐
- 论文赏析[EMNLP19]用控制任务来设计并解释探测任务
- 数组玩法(1):下标移位
- educoder平台答案Java_不会吧!不会还有人没有《java程序设计》学堂在线答案吧...
- JAVA多线程面试题整理及答案
- 如何绕过开机密码开启计算机,win10怎么绕过开机密码,win10如何强制跳过密码
- Linux拨号上网后自动断开,Ubuntu 12.10 拨号上网及停用方法
- 实验代做 行人识别_实验室代做实验项目
- Wirecast Pro 11 Mac(直播软件) v11.0.0中文破解版
- Jetson Nano 系列之:刷机、瘦身、部署应用
- numpy.random.rand(),numpy.random.randn(),numpy.random.normal()函数介绍和示例
- 软件测试常用的七大方法
热门文章
- 核桃编程学python吗_学编程要趁早?对话核桃编程X支付宝 “小程序编程马拉松”三强得主...
- 基于Minimax和Alpha-Beta剪枝实现的C语言五子棋AI入门
- 30W、45W、60W PD移动电源芯片方案+无线充方案
- 申论高效解题的步骤——按部就班
- 【数据结构】详解KMP算法
- 42个5G智慧教育应用场景,告诉你5G将如何改变教育
- maven 打包错误:Please refer to xxx\target\surefire-reports for the individual test results.
- 个人永久性免费-Excel催化剂功能第53波-无比期待的合并工作薄功能
- 我写的Javascript贪食蛇v1
- 前端三刺客---CSS