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 # Siguiente entrenamiento los programas tienen # para cumplir con los nombres de archivo del libro de trabajo de Excel de Excel de reconocimiento y el ws_qiyeshu = 0 qiyeshu_row = 0 qiyeshu_column = 0 ws_zichanzongji = 0 zichanzongji_row = 0 zichanzongji_column = 0 #################### ############################################# Bloquear balance general y Libro de trabajo # El siguiente código se usa para abrir múltiples tablas relacionadas fn = 'Balance Sheet.xlsx ' wb = openpyxl.load_workbook (fn) 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]) break ws = wb.get_sheet_by_name (sheet_selected.title) print (ws) ##### ###### 资产 负债 表 1 年初 存货 para fila en ws.iter_rows (): para celda en fila: if str (str (cell.value) .replace ('', '')). Find ("总计")! = -1: qiyeshu_row = celda.row else: ws_qiyeshu = 0 descanso para la fila en ws.iter_rows (): para celda en fila: if str (str (cell.value) .replace ('', '')). find ("企业 数")! = -1: qiyeshu_column = celda.column break if qiyeshu_row == 0 o qiyeshu_column == 0: ws_qiyeshu = 0 else: if ws.cell (fila = qiyeshu_row, column = qiyeshu_column) .value! = None: ws_qiyeshu = ws.cell (fila = qiyeshu_row, column = qiyeshu_column) .value print (ws_qiyeshu) para la fila en ws.iter_rows ( ): para la celda de la fila: if str (str (cell.value) .replace ('', '')). find ("总计")! = -1: zichanzongji_row = cell.row else: ws_zichanzongji = 0 descanso para la fila en ws.iter_rows (): para celda en fila: if str (str (cell.value) .replace ('', '')). find ("资产 总计")! = -1: zichanzongji_column = cell. salto de columna if zichanzongji_row == 0 o zichanzongji_column == 0: ws_zichanzongji = 0 else: if ws.cell (fila = zichanzongji_row, column = zichanzongji_column) .value! = Ninguno: ws_zichanzongji = ws.cell_column = zichanzongji ) .value print (ws_zichanzongji)
Informe financiero trimestral --- centrado en el contenido 02
Supongo que te gusta
Origin blog.csdn.net/jidawanghao/article/details/112819332
Recomendado
Clasificación