import os import win32com.client as win32 import shutil import openpyxl import time #####第一步先降原文件夹中的xlsx文件直接拷贝至bak文件夹中,切片r s t fn = '资产负债表.xlsx' wb = openpyxl.load_workbook(fn) ws = wb.get_sheet_by_name("资产负债表") ################################################锁定纳税申报表和工作薄 # 如下代码用于将多个表中的相关数据写入财务状况表 def getdate(date_row, date_column): row_result = 0 column_result = 0 result = 0 for row in ws.iter_rows(): for cell in row: for i in range(len(date_row)): if str(str(cell.value).replace(' ', '')).find(date_row[i]) != -1 and len(str(cell.value).replace(' ', '')) == len(date_row[i]) : row_result = cell.row #print(row_result) break for row in ws.iter_rows(): for cell in row: for i in range(len(date_column)): if str(str(cell.value).replace(' ', '')).find(date_column[i]) != -1 and len(str(cell.value).replace(' ', '')) == len(date_column[i]) : column_result = cell.column #print(column_result) break if row_result == 0 or column_result == 0: result = 0 else: if ws.cell(row = row_result , column = column_result).value != None: print(ws.cell(row=row_result, column=column_result).value) result = ws.cell(row=row_result, column=column_result).value return result if __name__ == '__main__': print(getdate(['存货'],['年初余额','年初数'])); print(getdate(['流动资产合计'],['期末余额','期末数'])); print(getdate(['应收账款'],['期末余额','期末数'])); print(getdate(['存货'],['期末余额','期末数'])); print(getdate(['固定资产原价'],['期末余额','期末数'])); print(getdate(['累计折旧'],['期末余额','期末数'])); print(getdate(['资产总计'],['期末余额','期末数'])); print(getdate(['负债合计'],['期末余额','期末数']));
简约而不简单 一键式统计 5.0
猜你喜欢
转载自blog.csdn.net/jidawanghao/article/details/112977671
今日推荐
周排行