# 修改了应交增值税 同比下降单位错误的问题
from docx import Document
from docx.shared import Inches
document = Document()
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
# 下一步还得训练程序
# 使其满足对excel文件名和excel工作薄的识别
# 记得把表格再粘贴下,转成仅值
ws = 0
row_result = 0
column_result = 0
result = 0
#####################################################################锁定资产负债表和工作薄
# 如下代码用于多个相关表的打开操作
fn = '疫情处置工作快报(第25期)附表24时.xlsx'
wb = openpyxl.load_workbook(fn)
ws = wb.get_sheet_by_name('表3三区')
ws02 = wb.get_sheet_by_name('表4济南市隔离点情况统计表')
# print(ws)
def getdate(ws,date_row, date_column, offset):
# print(date_row)
# print(date_column)
for row in ws.iter_rows():
for cell in row:
if str(str(cell.value).replace(' ', '')).find(date_row) != -1:
row_result = cell.row
# print(row_result)
else:
result = 0
break
for row in ws.iter_rows():
for cell in row:
if str(str(cell.value).replace(' ', '')).find(date_column) != -1:
column_result = cell.column + offset
# print(column_result)
break
# print(column_result)
if row_result == 0 or column_result == 0:
result = 0
else:
if ws.cell(row=row_result, column=column_result).value != None:
# print(column_result)
result = ws.cell(row=row_result, column=column_result).value
# print(result)
return result
if __name__ == '__main__':
#document.add_heading("财务季报评估报告")
################################
paragraph01 = document.add_paragraph('封控区')
paragraph01.add_run("封控区")
paragraph01.add_run(str(getdate(ws,'合计', '封控区个数',0)))
paragraph01.add_run("个,涉及")
fengkongqu_quxian = 0
if getdate(ws,'历下区', '封控区个数', 0) > 0:
fengkongqu_quxian = fengkongqu_quxian + 1
if getdate(ws,'市中区', '封控区个数', 0) > 0:
fengkongqu_quxian = fengkongqu_quxian + 1
if getdate(ws,'槐荫区', '封控区个数', 0) > 0:
fengkongqu_quxian = fengkongqu_quxian + 1
if getdate(ws,'天桥区', '封控区个数', 0) > 0:
fengkongqu_quxian = fengkongqu_quxian + 1
if getdate(ws,'历城区', '封控区个数', 0) > 0:
fengkongqu_quxian = fengkongqu_quxian + 1
if getdate(ws,'长清区', '封控区个数', 0) > 0:
fengkongqu_quxian = fengkongqu_quxian + 1
if getdate(ws,'章丘区', '封控区个数', 0) > 0:
fengkongqu_quxian = fengkongqu_quxian + 1
if getdate(ws,'济阳区', '封控区个数', 0) > 0:
fengkongqu_quxian = fengkongqu_quxian + 1
if getdate(ws,'莱芜区', '封控区个数', 0) > 0:
fengkongqu_quxian = fengkongqu_quxian + 1
if getdate(ws,'钢城区', '封控区个数', 0) > 0:
fengkongqu_quxian = fengkongqu_quxian + 1
if getdate(ws,'平阴县', '封控区个数', 0) > 0:
fengkongqu_quxian = fengkongqu_quxian + 1
if getdate(ws,'商河县', '封控区个数', 0) > 0:
fengkongqu_quxian = fengkongqu_quxian + 1
if getdate(ws,'高新区', '封控区个数', 0) > 0:
fengkongqu_quxian = fengkongqu_quxian + 1
if getdate(ws,'南部山区', '封控区个数', 0) > 0:
fengkongqu_quxian = fengkongqu_quxian + 1
if getdate(ws,'起步区', '封控区个数', 0) > 0:
fengkongqu_quxian = fengkongqu_quxian + 1
paragraph01.add_run(str(fengkongqu_quxian))
paragraph01.add_run("个区、")
paragraph01.add_run(str(getdate(ws,'合计', '封控区个数', 0)))
paragraph01.add_run("个区、")
paragraph01.add_run("?")
paragraph01.add_run("户、")
paragraph01.add_run(str(getdate(ws,'合计', '封控区个数', 1)))
paragraph01.add_run("人(其中,商河")
paragraph01.add_run(str(getdate(ws,'商河县', '封控区个数', 0)))
paragraph01.add_run("个,涉及")
paragraph01.add_run("?")
paragraph01.add_run("户、")
paragraph01.add_run(str(getdate(ws,'商河县', '封控区个数', 1)))
paragraph01.add_run("人;历城")
paragraph01.add_run(str(getdate(ws,'历城区', '封控区个数', 0)))
paragraph01.add_run("个,涉及")
paragraph01.add_run("?")
paragraph01.add_run("户、")
paragraph01.add_run(str(getdate(ws,'历城区', '封控区个数', 1)))
paragraph01.add_run("人),今日应采检")
paragraph01.add_run(str(getdate(ws,'合计', '封控区个数', 2)))
paragraph01.add_run("人,已采样")
paragraph01.add_run(str(getdate(ws,'合计', '封控区个数', 3)))
paragraph01.add_run("人,已出结果")
paragraph01.add_run(str(getdate(ws,'合计', '封控区个数', 4)))
# 封控区本轮检测结果为阳性的数量:print(getdate(ws,'合计', '封控区个数',4))
if (getdate(ws,'合计', '封控区个数', 5) == 0):
paragraph01.add_run("人,均为阴性。")
else:
paragraph01.add_run("人,其中阳性")
paragraph01.add_run(str(getdate(ws,'合计', '封控区个数', 5)))
paragraph01.add_run("人。")
################################
paragraph02 = document.add_paragraph('管控区')
paragraph02.add_run("管控区")
paragraph02.add_run(str(getdate(ws,'合计', '管控区个数', 0)))
paragraph02.add_run("个,涉及")
guankongqu_quxian = 0
if getdate(ws,'历下区', '管控区个数', 0) > 0:
guankongqu_quxian = guankongqu_quxian + 1
if getdate(ws,'市中区', '管控区个数', 0) > 0:
guankongqu_quxian = guankongqu_quxian + 1
if getdate(ws,'槐荫区', '管控区个数', 0) > 0:
guankongqu_quxian = guankongqu_quxian + 1
if getdate(ws,'天桥区', '管控区个数', 0) > 0:
guankongqu_quxian = guankongqu_quxian + 1
if getdate(ws,'历城区', '管控区个数', 0) > 0:
guankongqu_quxian = guankongqu_quxian + 1
if getdate(ws,'长清区', '管控区个数', 0) > 0:
guankongqu_quxian = guankongqu_quxian + 1
if getdate(ws,'章丘区', '管控区个数', 0) > 0:
guankongqu_quxian = guankongqu_quxian + 1
if getdate(ws,'济阳区', '管控区个数', 0) > 0:
guankongqu_quxian = guankongqu_quxian + 1
if getdate(ws,'莱芜区', '管控区个数', 0) > 0:
guankongqu_quxian = guankongqu_quxian + 1
if getdate(ws,'钢城区', '管控区个数', 0) > 0:
guankongqu_quxian = guankongqu_quxian + 1
if getdate(ws,'平阴县', '管控区个数', 0) > 0:
guankongqu_quxian = guankongqu_quxian + 1
if getdate(ws,'商河县', '管控区个数', 0) > 0:
guankongqu_quxian = guankongqu_quxian + 1
if getdate(ws,'高新区', '管控区个数', 0) > 0:
guankongqu_quxian = guankongqu_quxian + 1
if getdate(ws,'南部山区', '管控区个数', 0) > 0:
guankongqu_quxian = guankongqu_quxian + 1
if getdate(ws,'起步区', '管控区个数', 0) > 0:
guankongqu_quxian = guankongqu_quxian + 1
paragraph02.add_run(str(guankongqu_quxian))
paragraph02.add_run("个区、")
paragraph02.add_run("?")
paragraph02.add_run("户、")
paragraph02.add_run(str(getdate(ws,'合计', '管控区个数', 1)))
paragraph02.add_run("人(其中,商河")
paragraph02.add_run(str(getdate(ws,'商河县', '管控区个数', 0)))
paragraph02.add_run("个,涉及")
paragraph02.add_run("?")
paragraph02.add_run("户、")
paragraph02.add_run(str(getdate(ws,'商河', '管控区个数', 1)))
paragraph02.add_run("人;历城")
paragraph02.add_run(str(getdate(ws,'历城区', '管控区个数', 0)))
paragraph02.add_run("个,涉及")
paragraph02.add_run("?")
paragraph02.add_run("户、")
paragraph02.add_run(str(getdate(ws,'历城区', '管控区个数', 1)))
paragraph02.add_run("人),今日应采检")
paragraph02.add_run(str(getdate(ws,'合计', '管控区个数', 2)))
paragraph02.add_run("人,已采样")
paragraph02.add_run(str(getdate(ws,'合计', '管控区个数', 3)))
paragraph02.add_run("人,已出结果")
paragraph02.add_run(str(getdate(ws,'合计', '管控区个数', 4)))
# 管控区本轮检测结果为阳性的数量:print(getdate(ws,'合计', '管控区个数',4))
if (getdate(ws,'合计', '管控区个数', 5) == 0):
paragraph02.add_run("人,均为阴性。")
else:
paragraph02.add_run("人,其中阳性")
paragraph02.add_run(str(getdate(ws,'合计', '管控区个数', 5)))
paragraph02.add_run("人。")
################################
paragraph03 = document.add_paragraph('防范区')
# paragraph03.add_run(str(getdate(ws,'合计', '防范区个数', 0)))
paragraph03.add_run("个,涉及")
fangfanqu_quxian = 0
if getdate(ws,'历下区', '防范区个数', 0) > 0:
fangfanqu_quxian = fangfanqu_quxian + 1
if getdate(ws,'市中区', '防范区个数', 0) > 0:
fangfanqu_quxian = fangfanqu_quxian + 1
if getdate(ws,'槐荫区', '防范区个数', 0) > 0:
fangfanqu_quxian = fangfanqu_quxian + 1
if getdate(ws,'天桥区', '防范区个数', 0) > 0:
fangfanqu_quxian = fangfanqu_quxian + 1
if getdate(ws,'历城区', '防范区个数', 0) > 0:
fangfanqu_quxian = fangfanqu_quxian + 1
if getdate(ws,'长清区', '防范区个数', 0) > 0:
fangfanqu_quxian = fangfanqu_quxian + 1
if getdate(ws,'章丘区', '防范区个数', 0) > 0:
fangfanqu_quxian = fangfanqu_quxian + 1
if getdate(ws,'济阳区', '防范区个数', 0) > 0:
fangfanqu_quxian = fangfanqu_quxian + 1
if getdate(ws,'莱芜区', '防范区个数', 0) > 0:
fangfanqu_quxian = fangfanqu_quxian + 1
if getdate(ws,'钢城区', '防范区个数', 0) > 0:
fangfanqu_quxian = fangfanqu_quxian + 1
if getdate(ws,'平阴县', '防范区个数', 0) > 0:
fangfanqu_quxian = fangfanqu_quxian + 1
if getdate(ws,'商河县', '防范区个数', 0) > 0:
fangfanqu_quxian = fangfanqu_quxian + 1
if getdate(ws,'高新区', '防范区个数', 0) > 0:
fangfanqu_quxian = fangfanqu_quxian + 1
if getdate(ws,'南部山区', '防范区个数', 0) > 0:
fangfanqu_quxian = fangfanqu_quxian + 1
if getdate(ws,'起步区', '防范区个数', 0) > 0:
fangfanqu_quxian = fangfanqu_quxian + 1
paragraph03.add_run(str(fangfanqu_quxian))
paragraph03.add_run("个区、")
paragraph03.add_run("?")
paragraph03.add_run("户、")
paragraph03.add_run(str(getdate(ws,'合计', '防范区个数', 1)))
paragraph03.add_run("人,今日应采检")
paragraph03.add_run(str(getdate(ws,'合计', '防范区个数', 2)))
paragraph03.add_run("人,已采样")
paragraph03.add_run(str(getdate(ws,'合计', '防范区个数', 3)))
paragraph03.add_run("人,已出结果")
paragraph03.add_run(str(getdate(ws,'合计', '防范区个数', 4)))
# 防范区本轮检测结果为阳性的数量:print(getdate(ws,'合计', '防范区个数',4))
if (getdate(ws,'合计', '防范区个数', 5) == 0):
paragraph03.add_run("人,均为阴性。")
else:
paragraph03.add_run("人,其中阳性")
paragraph03.add_run(str(getdate(ws,'合计', '防范区个数', 5)))
paragraph03.add_run("人。")
# paragraph101.add_run('个')
################################
paragraph04 = document.add_paragraph("截至目前,全市现有储备隔离点总数")
paragraph04.add_run(str(getdate(ws02,'济南市', '地区', 1)))
paragraph04.add_run("个,房间")
paragraph04.add_run(str(getdate(ws02,'济南市', '地区', 2)))
paragraph04.add_run(",其中,已启用隔离点")
paragraph04.add_run(str(getdate(ws02,'济南市', '地区', 3)))
paragraph04.add_run("个,房间")
paragraph04.add_run(str(getdate(ws02,'济南市', '地区', 4)))
paragraph04.add_run("间,已用房间")
paragraph04.add_run(str(getdate(ws02,'济南市', '地区', 5)))
paragraph04.add_run("间,空余房间")
zongshu = int(getdate(ws02,'济南市', '地区', 4))
yiyong= int(getdate(ws02,'济南市', '地区', 5))
kongyu = 0
print(zongshu)
print(yiyong)
kongyu = zongshu - yiyong
print(kongyu)
paragraph04.add_run(str(kongyu))
paragraph04.add_run("间。空余房间中可即时投入使用的房间")
paragraph04.add_run(str(getdate(ws02,'济南市', '地区', 6)))
paragraph04.add_run("间、入境人员备用房间")
paragraph04.add_run(str(getdate(ws02,'济南市', '地区', 7)))
paragraph04.add_run("间、其他房间")
paragraph04.add_run(str(getdate(ws02,'济南市', '地区', 8)))
paragraph04.add_run("间(正在消杀或因设施维修等原因不能立即投入使用)。")
document.save('疫情处置快报.docx')
|