Quarterly financial report 0.1

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 

# Next Also have to train the program 
# to meet the recognition of excel file name and excel workbook 


ws_qiyeshu = 0 
qiyeshu_row = 0 
qiyeshu_column = 0 



ws_zichanofficer = 0 
zichan_row = 0 
zichan_column = 0 

ws_zichanchan_rowzengsu = 0 
zichan 
zichan_officers = 0 


column zengsu = 0 
zichan_zengsu_officers = 0 
zichanofficer_column = 0








############################################## ##################Lock balance sheet and workbook 
# The following code is used to open multiple related tables 
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("Balance Sheet") != -1: 
                sheet_selected = wb.get_sheet_by_name(allSheets[i]) 

                break 

ws = wb.get_sheet_by_name(sheet_selected .title) 
print(ws) 


########### Jinan City Financial Quarterly Report Report Unit Number 


for row in ws.iter_rows(): 
    for cell in row:
        if str(str(cell.value).replace(' ', '')).find("总计") != -1:
            qiyeshu_row = cell.row
        else:
            ws_qiyeshu = 0

            break
for row in ws.iter_rows():
    for cell in row:
        if str(str(cell.value).replace(' ', '')).find("企业数") != -1 :
            qiyeshu_column = cell.column

            break

if qiyeshu_row == 0 or qiyeshu_column == 0:
    ws_qiyeshu = 0
else:
    if ws.cell(row=qiyeshu_row, column=qiyeshu_column).value != None:
        ws_qiyeshu = ws.cell(row=qiyeshu_row, column=qiyeshu_column).value
        print(ws_qiyeshu)



##################全市限额以上企业资产总计

for row in ws.iter_rows():
    for cell in row:
        if str(str(cell.value).replace(' ', '')).find("总计") != -1:
            zichanzongji_row = cell.row
        else:
            ws_zichanzongji = 0

            break
for row in ws.iter_rows():
    for cell in row:
        if str(str(cell.value).replace(' ', '')).find("资产总计") != -1 :
            zichanzongji_column = cell.column

            break

if zichanzongji_row == 0 or zichanzongji_column == 0:
    ws_zichanzongji = 0
else:
    if ws.cell(row=zichanzongji_row, column=zichanzongji_column).value != None:
        ws_zichanzongji = ws.cell(row=zichanzongji_row, column=zichanzongji_column).value
        print(ws_zichanzongji)



#####################同比增长


for row in ws.iter_rows():
    for cell in row:
        if str(str(cell.value).replace(' ', '')).find("总计") != -1:
            zichanzongjizengsu_row = cell.row
        else:
            ws_zichanzongjizengsu = 0

            break
for row in ws.iter_rows():
    for cell in row:
        if str(str(cell.value).replace(' ', '')).find("资产总计") != -1 :
            zichanzongjizengsu_column = cell.column + 2

            break

if zichanzongjizengsu_row == 0 or zichanzongjizengsu_column == 0:
    ws_zichanzongjizengsu = 0
else:
    if ws.cell(row=zichanzongjizengsu_row, column=zichanzongjizengsu_column).value != None:
        ws_zichanzongjizengsu = ws.cell(row=zichanzongjizengsu_row, column=zichanzongjizengsu_column).value
        print(ws_zichanzongjizengsu)

##################批发业企业资产总计

for row in ws.iter_rows():
    for cell in row:
        if str(str(cell.value).replace(' ', '')).find("一、批发业") != -1:
            pifazichanzongji_row = cell.row
        else:
            ws_pifazichanzongji = 0

            break
for row in ws.iter_rows():
    for cell in row:
        if str(str(cell.value).replace(' ', '')).find("资产总计") != -1 :
            pifazichanzongji_column = cell.column

            break

if pifazichanzongji_row == 0 or pifazichanzongji_column == 0:
    ws_pifazichanzongji = 0
else:
    if ws.cell(row=pifazichanzongji_row, column=pifazichanzongji_column).value != None:
        ws_pifazichanzongji = ws.cell(row=pifazichanzongji_row, column=pifazichanzongji_column).value
        print(ws_pifazichanzongji)

#########################
for row in ws.iter_rows():
    for cell in row:
        if str(str(cell.value).replace(' ', '')).find("一、批发业") != -1:
            pifazichanzongjizs_row = cell.row
        else:
            ws_pifazichanzongjizs = 0

            break
for row in ws.iter_rows():
    for cell in row:
        if str(str(cell.value).replace(' ', '')).find("资产总计") != -1 :
            pifazichanzongjizs_column = cell.column + 2

            break

if pifazichanzongjizs_row == 0 or pifazichanzongjizs_column == 0:
    ws_pifazichanzongjizs = 0
else:
    if ws.cell(row=pifazichanzongjizs_row, column=pifazichanzongjizs_column).value != None:
        ws_pifazichanzongjizs = ws.cell(row=pifazichanzongjizs_row, column=pifazichanzongjizs_column).value
        print(ws_pifazichanzongjizs)

########################################

for row in ws.iter_rows():
    for cell in row:
        if str(str(cell.value).replace(' ', '')).find("二、零售业") != -1:
            lingshouzichanzongji_row = cell.row
        else:
            ws_lingshouzichanzongji = 0

            break
for row in ws.iter_rows():
    for cell in row:
        if str(str(cell.value).replace(' ', '')).find("资产总计") != -1 :
            lingshouzichanzongji_column = cell.column

            break

if lingshouzichanzongji_row == 0 or lingshouzichanzongji_column == 0:
    ws_lingshouzichanzongji = 0
else:
    if ws.cell(row=lingshouzichanzongji_row, column=lingshouzichanzongji_column).value != None:
        ws_lingshouzichanzongji = ws.cell(row=lingshouzichanzongji_row, column=lingshouzichanzongji_column).value
        print(ws_lingshouzichanzongji)

#########################
for row in ws.iter_rows():
    for cell in row:
        if str(str(cell.value).replace(' ', '')).find("二、零售业") != -1:
            lingshouzichanzongjizs_row = cell.row
        else:
            ws_lingshouzichanzongjizs = 0

            break
for row in ws.iter_rows():
    for cell in row:
        if str(str(cell.value).replace(' ', '')).find("资产总计") != -1 :
            lingshouzichanzongjizs_column = cell.column + 2

            break

if lingshouzichanzongjizs_row == 0 or lingshouzichanzongjizs_column == 0:
    ws_lingshouzichanzongjizs = 0
else:
    if ws.cell(row=lingshouzichanzongjizs_row, column=lingshouzichanzongjizs_column).value != None:
        ws_lingshouzichanzongjizs = ws.cell(row=lingshouzichanzongjizs_row, column=lingshouzichanzongjizs_column).value
        print(ws_lingshouzichanzongjizs)


#####################################################

for row in ws.iter_rows():
    for cell in row:
        if str(str(cell.value).replace(' ', '')).find("3. Accommodation industry") != -1:
            zhusuzichanzongji_row = cell.row
        else:
            ws_zhusuzichanzongji = 0

            break
for row in ws.iter_rows():
    for cell in row:
        if str(str(cell.value).replace(' ', '')).find("资产总计") != -1:
            zhusuzichanzongji_column = cell.column

            break

if zhusuzichanzongji_row == 0 or zhusuzichanzongji_column == 0:
    ws_zhusuzichanzongji = 0
else:
    if ws.cell(row=zhusuzichanzongji_row, column=zhusuzichanzongji_column).value != None:
        ws_zhusuzichanzongji = ws.cell(row=zhusuzichanzongji_row, column=zhusuzichanzongji_column).value
        print(ws_zhusuzichanzongji)

#########################
for row in ws.iter_rows():
    for cell in row:
        if str(str(cell.value).replace(' ', '')).find("三、住宿业") != -1:
            zhusuzichanzongjizs_row = cell.row
        else:
            ws_zhusuzichanzongjizs = 0

            break
for row in ws.iter_rows():
    for cell in row:
        if str(str(cell.value).replace(' ', '')).find("资产总计") != -1:
            zhusuzichanzongjizs_column = cell.column + 2

            break

if zhusuzichanzongjizs_row == 0 or zhusuzichanzongjizs_column == 0:
    ws_zhusuzichanzongjizs = 0
else:
    if ws.cell(row=zhusuzichanzongjizs_row, column=zhusuzichanzongjizs_column).value != None:
        ws_zhusuzichanzongjizs = ws.cell(row=zhusuzichanzongjizs_row, column=zhusuzichanzongjizs_column).value
        print(ws_zhusuzichanzongjizs)
##############################################################################


for row in ws.iter_rows():
    for cell in row:
        if str(str(cell.value).replace(' ', '')).find("四、餐饮业") != -1:
            canyinzichanzongji_row = cell.row
        else:
            ws_canyinzichanzongji = 0

            break
for row in ws.iter_rows():
    for cell in row:
        if str(str(cell.value).replace(' ', '')).find("资产总计") != -1:
            canyinzichanzongji_column = cell.column

            break

if canyinzichanzongji_row == 0 or canyinzichanzongji_column == 0:
    ws_canyinzichanzongji = 0
else:
    if ws.cell(row=canyinzichanzongji_row, column=canyinzichanzongji_column).value != None:
        ws_canyinzichanzongji = ws.cell(row=canyinzichanzongji_row, column=canyinzichanzongji_column).value
        print(ws_canyinzichanzongji)

#########################
for row in ws.iter_rows():
    for cell in row:
        if str(str(cell.value).replace(' ', '')).find("四、餐饮业") != -1:
            canyinzichanzongjizs_row = cell.row
        else:
            ws_canyinzichanzongjizs = 0

            break
for row in ws.iter_rows():
    for cell in row:
        if str(str(cell.value).replace(' ', '')).find("资产总计") != -1:
            canyinzichanzongjizs_column = cell.column + 2

            break

if canyinzichanzongjizs_row == 0 or canyinzichanzongjizs_column == 0:
    ws_canyinzichanzongjizs = 0
else:
    if ws.cell(row=canyinzichanzongjizs_row, column=canyinzichanzongjizs_column).value != None:
        ws_canyinzichanzongjizs = ws.cell(row=canyinzichanzongjizs_row, column=canyinzichanzongjizs_column).value
        print(ws_canyinzichanofficerzs) 
########################################### ##############

Guess you like

Origin blog.csdn.net/jidawanghao/article/details/112826206