import os import win32com.client as win32 import shutil import openpyxl import time #####The first step is to drop the xlsx file in the original folder and copy it directly to the bak folder, slice rst fn ='balance sheet.xlsx' wb = openpyxl.load_workbook(fn) ws = wb.get_sheet_by_name("Balance Sheet") ############################# #################Lock tax return and workbook # The following code is used to write the relevant data in multiple tables into the financial status table 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(['Inventory'],[' Year balance','Year number']) ); print(getdate(['Total current assets'],['Ending balance','Ending amount'])); print(getdate(['Accounts receivable'],['Ending balance','Ending amount '])); print(getdate(['Inventory'],['Ending balance','Ending amount'])); print(getdate(['Original price of fixed assets'],['Ending balance','Ending amount '])); print(getdate(['cumulative depreciation'],['end balance','end balance'])); print(getdate(['total assets'],['end balance','end balance '])); print(getdate(['Total liabilities'],['Balance at the end of the period','Amount at the end of the period']));
Simple but not simple one-click statistics 5.0
Guess you like
Origin blog.csdn.net/jidawanghao/article/details/112977671
Ranking