四半期財務報告---コンテンツに焦点を当てる02

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 

#次のトレーニングプログラムには
、認識を満たすための#があります


。ExcelExcelワークブックのファイル名とws_qiyeshu = 0 
qiyeshu_row = 0 
qiyeshu_column = 0 



ws_zichanzongji = 0 
zichanzongji_row = 0 
zichanzongji_column = 0 











############### ### ###############################################ロックバランスシートおよびワークブック
#次のコードは、複数の関連テーブルを開くために使用されます
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年初存货


ws.iter_rows()の
    行の
        場合:行のセルの場合if str(str(cell.value).replace( ''、 ''))。find( "总计")!= -1:
            qiyeshu_row = cell.row 
        else:
            ws_qiyeshu = 0
    行のセルの

            ブレーク 
ws.iter_rows()の行の
        if str(str(cell.value).replace( ''、 ''))。find( "企业数")!= -1:
            qiyeshu_column = cell.column 

            break 

if qiyeshu_row == 0または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( ):
    行のセルの
        場合if str(str(cell.value).replace( ''、 ''))。find( "
            总计")!= -1:zichanzongji_row = cell.row 
        else:
            ws_zichanzongji = 0

            ブレーク
ws.iter_rows()の
    行の
        場合:行のセルの場合if str(str(cell.value).replace( ''、 ''))。find( "资β总计")!= -1:
            zichanzongji_column = cell。
zichanzongji_row == 0またはzichanzongji_column == 0の場合は

            ブレーク

    ws_zichanzongji = 0 
else:
    ws.cell(row = zichanzongji_row、column = zichanzongji_column).value!=なし:
        ws_zichanzongji = ws.cell(row = zichanzongji_row、column = zi )
        .value print(ws_zichanzongji)

おすすめ

転載: blog.csdn.net/jidawanghao/article/details/112819332