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 = '资产负债表.xlsx' wb = openpyxl.load_workbook(fn) ws = wb.get_sheet_by_name('资产负债表') # print(ws) def getdate(date_row, date_column): # 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 # 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 def getdate_lastyear(date_row, date_column): # 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 + 1 # 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 def getspeed(date_row, date_column): # 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 + 2 # 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("财务季报评估报告") paragraph100 = document.add_paragraph('一、四行业总体情况') paragraph101 = document.add_paragraph('1-3季度,济南市财务季报上报单位') paragraph101.add_run(str(round(getdate('总计', '企业数'), 1))) paragraph101.add_run('个') paragraph101.add_run("。其中批发业企业") paragraph101.add_run("个,占比") paragraph101.add_run("%;零售业企业") paragraph101.add_run("个,占比") paragraph101.add_run("%;住宿业企业") paragraph101.add_run("个,占比") paragraph101.add_run("%;餐饮业企业") paragraph101.add_run("个,占比") paragraph101.add_run("%。") paragraph200 = document.add_paragraph('二、财务数据分析') paragraph201 = document.add_paragraph('1、资产情况。1-2季度,全市限额以上企业资产总计') paragraph201.add_run(str(round(getdate('总计', '资产总计'), 1))) paragraph201.add_run('亿元,') if(round(getspeed('总计', '资产总计'), 1) > 0): paragraph201.add_run('同比增长') else: paragraph201.add_run('同比下降') paragraph201.add_run(str(round(getspeed('总计', '资产总计'), 1))) paragraph201.add_run('%。其中,批发业企业资产总计') paragraph201.add_run(str(round(getdate('一、批发业', '资产总计'), 1))) paragraph201.add_run('亿元,') if(round(getspeed('一、批发业', '资产总计'), 1) > 0): paragraph201.add_run('同比增长') else: paragraph201.add_run('同比下降') paragraph201.add_run(str(round(getspeed('一、批发业', '资产总计'), 1))) paragraph201.add_run('%;零售业企业资产总计') paragraph201.add_run(str(round(getdate('二、零售业', '资产总计'), 1))) paragraph201.add_run('亿元,') ############# if(round(getspeed('二、零售业', '资产总计'), 1) > 0): paragraph201.add_run('同比增长') else: paragraph201.add_run('同比下降') paragraph201.add_run(str(round(getspeed('二、零售业', '资产总计'), 1))) paragraph201.add_run('%;住宿业企业资产总计') paragraph201.add_run(str(round(getdate('三、住宿业', '资产总计'), 1))) paragraph201.add_run('亿元,') if(round(getspeed('三、住宿业', '资产总计'), 1) > 0): paragraph201.add_run('同比增长') else: paragraph201.add_run('同比下降') paragraph201.add_run(str(round(getspeed('三、住宿业', '资产总计'), 1))) paragraph201.add_run('%;餐饮业企业资产总计') paragraph201.add_run(str((getdate('四、餐饮业', '资产总计'), 1))) paragraph201.add_run('亿元,') if(round(getspeed('四、餐饮业', '资产总计'), 1) > 0): paragraph201.add_run('同比增长') else: paragraph201.add_run('同比下降') paragraph201.add_run(str(round(getspeed('四、餐饮业', '资产总计'), 1))) paragraph201.add_run('%。') ############################################### paragraph202 = document.add_paragraph('2、负债情况。1-2季度,全市限额以上企业负债合计') paragraph202.add_run(str(round(getdate('总计', '负债合计'), 1))) paragraph202.add_run('亿元,') if(round(getspeed('总计', '负债合计'), 1) > 0): paragraph202.add_run('同比增长') else: paragraph202.add_run('同比下降') paragraph202.add_run(str(round(getspeed('总计', '负债合计'), 1))) paragraph202.add_run('%。其中,批发业企业负债合计') paragraph202.add_run(str(round(getdate('一、批发业', '负债合计'), 1))) paragraph202.add_run('亿元,') if(round(getspeed('一、批发业', '资产总计'), 1) > 0): paragraph202.add_run('同比增长') else: paragraph202.add_run('同比下降') paragraph202.add_run(str(round(getspeed('一、批发业', '负债合计'), 1))) paragraph202.add_run('%;零售业企业负债合计') paragraph202.add_run(str(round(getdate('二、零售业', '负债合计'), 1))) paragraph202.add_run('亿元,') if(round(getspeed('二、零售业', '负债合计'), 1) > 0): paragraph202.add_run('同比增长') else: paragraph202.add_run('同比下降') paragraph202.add_run(str(round(getspeed('二、零售业', '负债合计'), 1))) paragraph202.add_run('%;住宿业企业负债合计') paragraph202.add_run(str(round(getdate('三、住宿业', '负债合计'), 1))) paragraph202.add_run('亿元,') if(round(getspeed('三、住宿业', '负债合计'), 1) > 0): paragraph202.add_run('同比增长') else: paragraph202.add_run('同比下降') paragraph202.add_run(str(round(getspeed('三、住宿业', '负债合计'), 1))) paragraph202.add_run('%;餐饮业企业负债合计') paragraph202.add_run(str(round(getdate('四、餐饮业', '负债合计'), 1))) paragraph202.add_run('亿元,') if(round(getspeed('四、餐饮业', '负债合计'), 1) > 0): paragraph202.add_run('同比增长') else: paragraph202.add_run('同比下降') paragraph202.add_run(str(round(getspeed('四、餐饮业', '负债合计'), 1))) paragraph202.add_run('%。') ################################## paragraph203 = document.add_paragraph('3、营业收入。1-2季度,全市限额以上企业实现营业收入' paragraph203.add_run(str(round(getdate('总计', '营业收入'), 1) paragraph203.add_run('亿元,同比下降') if(round(getspeed('总计', '营业收入'), 1) > 0): paragraph203.add_run('同比增长') else: paragraph203.add_run('同比下降') paragraph203.add_run(str(round(getspeed('总计', '营业收入'), 1) paragraph203.add_run('%。其中,批发业企业实现营业收入' paragraph203.add_run(str(round(getdate('一、批发业', '营业收入'), 1) paragraph203.add_run('亿元,同比增长') if(round(getspeed('一、批发业', '营业收入'), 1) > 0): paragraph203.add_run('同比增长') else: paragraph203.add_run('同比下降') paragraph203.add_run(str(round(getspeed('一、批发业', '营业收入'), 1))) paragraph203.add_run('%;零售业企业营业收入') paragraph203.add_run(str(round(getdate('二、零售业', '营业收入'), 1) paragraph203.add_run('亿元,同比下降') if(round(getspeed('二、零售业', '营业收入'), 1) > 0): paragraph203.add_run('同比增长') else: paragraph203.add_run('同比下降') paragraph203.add_run(str(round(getspeed('二、零售业', '营业收入'), 1) paragraph203.add_run('%;住宿业企业营业收入') paragraph203.add_run(str(round(getdate('三、住宿业', '营业收入'), 1) paragraph203.add_run('亿元,同比下降') if(round(getspeed('三、住宿业', '营业收入'), 1) > 0): paragraph203.add_run('同比增长') else: paragraph203.add_run('同比下降') paragraph203.add_run(str(round(getspeed('三、住宿业', '营业收入'), 1) paragraph203.add_run('%;餐饮业企业营业收入' paragraph203.add_run(str(round(getdate('四、餐饮业', '营业收入'), 1) paragraph203.add_run('亿元,同比下降' if(round(getspeed('四、餐饮业', '营业收入'), 1) > 0): paragraph203.add_run('同比增长') else: paragraph203.add_run('同比下降') paragraph203.add_run(str(round(getspeed('四、餐饮业', '营业收入'), 1) paragraph203.add_run('%。') #################################### ''' paragraph204 = document.add_paragraph('4、营业成本。1-2季度,全市限额以上企业营业成本合计' paragraph204.add_run(str(round(getdate('总计', '营业成本'), 1) paragraph204.add_run('亿元,同比下降' if(round(getspeed('四、餐饮业', '营业收入'), 1) > 0): paragraph204.add_run('同比增长') else: paragraph204.add_run('同比下降') paragraph204.add_run(str(round(getspeed('总计', '营业成本'), 1) paragraph204.add_run('%。其中,批发业企业营业成本' paragraph204.add_run(str(round(getdate('一、批发业', '营业成本'), 1) paragraph204.add_run('亿元,同比增长' if(round(getspeed('四、餐饮业', '营业收入'), 1) > 0): paragraph204.add_run('同比增长') else: paragraph204.add_run('同比下降') paragraph204.add_run(str(round(getspeed('一、批发业', '营业成本'), 1) paragraph204.add_run('%;零售业企业营业成本' paragraph204.add_run(str(round(getdate('二、零售业', '营业成本'), 1) paragraph204.add_run('亿元,同比下降' if(round(getspeed('四、餐饮业', '营业收入'), 1) > 0): paragraph204.add_run('同比增长') else: paragraph204.add_run('同比下降') paragraph204.add_run(str( round(getspeed('二、零售业', '营业成本'), 1) paragraph204.add_run('%;住宿业企业营业成本' paragraph204.add_run(str(round(getdate('三、住宿业', '营业成本'), 1) paragraph204.add_run('亿元,同比下降' if(round(getspeed('四、餐饮业', '营业收入'), 1) > 0): paragraph204.add_run('同比增长') else: paragraph204.add_run('同比下降') round(getspeed('三、住宿业', '营业成本'), 1) paragraph204.add_run('%;餐饮业企业营业成本合计' paragraph204.add_run( round(getdate('四、餐饮业', '营业成本'), 1) paragraph204.add_run('亿元,同比下降' if(round(getspeed('四、餐饮业', '营业收入'), 1) > 0): paragraph204.add_run('同比增长') else: paragraph204.add_run('同比下降') paragraph204.add_run(str(round(getspeed('四、餐饮业', '营业成本'), 1) paragraph204.add_run('%。') paragraph205 = document.add_paragraph('5、营业税金。1-2季度,全市限额以上企业税金及附加合计' paragraph205.add_run(str(round(getdate('总计', '税金及附加'), 1) paragraph205.add_run('亿元,同比下降' if(round(getspeed(), 1) > 0): paragraph205.add_run('同比增长') else: paragraph205.add_run('同比下降') paragraph205.add_run(str(round(getspeed('总计', '税金及附加'), 1) paragraph205.add_run('%。其中,批发业企业税金及附加合计' paragraph205.add_run(str(round(getdate('一、批发业', '税金及附加'), 1) paragraph205.add_run('亿元,同比下降' if(round(getspeed(), 1) > 0): paragraph205.add_run('同比增长') else: paragraph205.add_run('同比下降') paragraph205.add_run(str(round(getspeed('一、批发业', '税金及附加'), 1) paragraph205.add_run('%,零售业企业税金及附加合计' paragraph205.add_run(str(round(getdate('二、零售业', '税金及附加'), 1) paragraph205.add_run('亿元,同比下降' if(round(getspeed(), 1) > 0): paragraph205.add_run('同比增长') else: paragraph205.add_run('同比下降') paragraph205.add_run(str(round(getspeed('二、零售业', '税金及附加'), 1) paragraph205.add_run('%;住宿业企业税金及附加合计' paragraph205.add_run(str(round(getdate('三、住宿业', '税金及附加'), 1) paragraph205.add_run('亿元,同比下降' if(round(getspeed(), 1) > 0): paragraph205.add_run('同比增长') else: paragraph205.add_run('同比下降') paragraph205.add_run(str(round(getspeed('三、住宿业', '税金及附加'), 1) paragraph205.add_run('%;餐饮业企业税金及附加合计' paragraph205.add_run(str(round(getdate('四、餐饮业', '税金及附加'), 1) paragraph205.add_run('亿元,同比下降' if(round(getspeed(), 1) > 0): paragraph205.add_run('同比增长') else: paragraph205.add_run('同比下降') paragraph205.add_run(str(round(getspeed('四、餐饮业', '税金及附加'), 1) paragraph205.add_run('%。') paragraph206 = document.add_paragraph('6、四项费用。1-2季度,全市限额以上企业销售费用、管理费用、研发费用及财务费用合计' paragraph206.add_run(str( round(getdate('总计', '销售费用') + getdate('总计', '管理费用') + getdate('总计', '研发费用') + getdate('总计', '财务费用'), 1) paragraph206.add_run('亿元,同比下降' if(round(getspeed(), 1) > 0): paragraph206.add_run('同比增长') else: paragraph206.add_run('同比下降') paragraph206.add_run(str( round(getdate('一、批发业', '销售费用') + getdate('一、批发业', '管理费用') + getdate('一、批发业', '研发费用') + getdate('一、批发业', '财务费用'), 1) round(((getdate('一、批发业', '销售费用') + getdate('一、批发业', '管理费用') + getdate('一、批发业', '研发费用') + getdate('一、批发业', '财务费用')) / ( getdate_lastyear('一、批发业', '销售费用') + getdate_lastyear('一、批发业', '管理费用') + getdate_lastyear( '一、批发业', '研发费用') + getdate_lastyear('一、批发业', '财务费用')) - 1) * 100, 1) ) paragraph206.add_run('%。其中批发业企业四项费用合计' paragraph206.add_run(str(round(getdate('一、批发业', '销售费用') + getdate('一、批发业', '管理费用') + getdate('一、批发业', '研发费用') + getdate('一、批发业', '财务费用'), 1) paragraph206.add_run('亿元,同比下降' if(round(getspeed(), 1) > 0): paragraph206.add_run('同比增长') else: paragraph206.add_run('同比下降') paragraph206.add_run(str(round(((getdate('一、批发业', '销售费用') + getdate('一、批发业', '管理费用') + getdate('一、批发业', '研发费用') + getdate('一、批发业', '财务费用')) / ( getdate_lastyear('一、批发业', '销售费用') + getdate_lastyear('一、批发业', '管理费用') + getdate_lastyear( '一、批发业', '研发费用') + getdate_lastyear('一、批发业', '财务费用')) - 1) * 100, 1) ) paragraph206.add_run('%;零售业企业四项费用合计' paragraph206.add_run(str(round(getdate('二、零售业', '销售费用') + getdate('二、零售业', '管理费用') + getdate('二、零售业', '研发费用') + getdate('二、零售业', '财务费用'), 1) paragraph206.add_run('亿元,同比下降' if(round(getspeed(), 1) > 0): paragraph206.add_run('同比增长') else: paragraph206.add_run('同比下降') paragraph206.add_run(str(round(((getdate('二、零售业', '销售费用') + getdate('二、零售业', '管理费用') + getdate('二、零售业', '研发费用') + getdate('二、零售业', '财务费用')) / ( getdate_lastyear('二、零售业', '销售费用') + getdate_lastyear('二、零售业', '管理费用') + getdate_lastyear( '二、零售业', '研发费用') + getdate_lastyear('二、零售业', '财务费用')) - 1) * 100, 1) ) paragraph206.add_run('%;住宿业企业四项费用合计' paragraph206.add_run(str(round(getdate('三、住宿业', '销售费用') + getdate('三、住宿业', '管理费用') + getdate('三、住宿业', '研发费用') + getdate('三、住宿业', '财务费用'), 1) paragraph206.add_run('亿元,同比下降' if(round(getspeed(), 1) > 0): paragraph206.add_run('同比增长') else: paragraph206.add_run('同比下降') paragraph206.add_run(str(round(((getdate('三、住宿业', '销售费用') + getdate('三、住宿业', '管理费用') + getdate('三、住宿业', '研发费用') + getdate('三、住宿业', '财务费用')) / ( getdate_lastyear('三、住宿业', '销售费用') + getdate_lastyear('三、住宿业', '管理费用') + getdate_lastyear( '三、住宿业', '研发费用') + getdate_lastyear('三、住宿业', '财务费用')) - 1) * 100, 1) ) paragraph206.add_run('%;餐饮业企业四项费用合计' paragraph206.add_run(str(round(getdate('四、餐饮业', '销售费用') + getdate('四、餐饮业', '管理费用') + getdate('四、餐饮业', '研发费用') + getdate('四、餐饮业', '财务费用'), 1) paragraph206.add_run('亿元,同比下降' if(round(getspeed(), 1) > 0): paragraph206.add_run('同比增长') else: paragraph206.add_run('同比下降') paragraph206.add_run(str(round(((getdate('四、餐饮业', '销售费用') + getdate('四、餐饮业', '管理费用') + getdate('四、餐饮业', '研发费用') + getdate('四、餐饮业', '财务费用')) / ( getdate_lastyear('四、餐饮业', '销售费用') + getdate_lastyear('四、餐饮业', '管理费用') + getdate_lastyear( '四、餐饮业', '研发费用') + getdate_lastyear('四、餐饮业', '财务费用')) - 1) * 100, 1) ) paragraph206.add_run('%。') #################### paragraph207 = document.add_paragraph('7、营业利润。1-2季度,全市限额以上企业营业利润合计' paragraph207.add_run(str(round(getdate('总计', '营业利润'), 1) paragraph207.add_run('亿元,同比下降' if(round(getspeed(), 1) > 0): paragraph207.add_run('同比增长') else: paragraph207.add_run('同比下降') paragraph207.add_run(str(round(getspeed('总计', '营业利润'), 1) paragraph207.add_run('%。批发业企业营业利润合计' paragraph207.add_run(str(round(getdate('一、批发业', '营业利润'), 1) paragraph207.add_run('亿元,同比增长' if(round(getspeed(), 1) > 0): paragraph207.add_run('同比增长') else: paragraph207.add_run('同比下降') paragraph207.add_run(str(round(getspeed('一、批发业', '营业利润'), 1) paragraph207.add_run('%;零售业企业营业利润合计' paragraph207.add_run(str(round(getdate('二、零售业', '营业利润'), 1) paragraph207.add_run('亿元,同比下降' if(round(getspeed(), 1) > 0): paragraph207.add_run('同比增长') else: paragraph207.add_run('同比下降') paragraph207.add_run(str(round(getspeed('二、零售业', '营业利润'), 1) paragraph207.add_run('%;住宿业企业营业利润合计' paragraph207.add_run(str(round(getdate('三、住宿业', '营业利润'), 1) paragraph207.add_run('亿元,而去年同期为' if(round(getspeed(), 1) > 0): paragraph207.add_run('同比增长') else: paragraph207.add_run('同比下降') paragraph207.add_run(str(round(getspeed('三、住宿业', '营业利润'), 1) paragraph207.add_run('亿元;餐饮业企业营业利润合计' paragraph207.add_run(str(round(getdate('四、餐饮业', '营业利润'), 1) paragraph207.add_run('亿,而去年同期为' if(round(getspeed(), 1) > 0): paragraph207.add_run('同比增长') else: paragraph207.add_run('同比下降') paragraph207.add_run(str(round(getspeed('四、餐饮业', '营业利润'), 1) paragraph207.add_run('亿元。') paragraph208 = document.add_paragraph('8、应交增值税。1-2季度,全市限额以上企业应交增值税合计' paragraph208.add_run(str(round(getdate('总计', '应交增值税'), 1) paragraph208.add_run('亿元,而去年同期为' if(round(getspeed(), 1) > 0): paragraph208.add_run('同比增长') else: paragraph208.add_run('同比下降') paragraph208.add_run(str(round(getspeed('总计', '应交增值税'), 1) paragraph208.add_run('亿元。其中批发业企业应交增值税合计' paragraph208.add_run(str(round(getdate('一、批发业', '应交增值税'), 1) paragraph208.add_run('亿元,而去年同期为' if(round(getspeed(), 1) > 0): paragraph208.add_run('同比增长') else: paragraph208.add_run('同比下降') paragraph208.add_run(str(round(getspeed('一、批发业', '应交增值税'), 1) paragraph208.add_run('亿元;零售业企业应交增值税合计' paragraph208.add_run(str(round(getdate('二、零售业', '应交增值税'), 1) paragraph208.add_run('亿元,同比下降' if(round(getspeed(), 1) > 0): paragraph208.add_run('同比增长') else: paragraph208.add_run('同比下降') paragraph208.add_run(str(round(getspeed('二、零售业', '应交增值税'), 1) paragraph208.add_run('%;住宿业企业应交增值税合计' paragraph208.add_run(str(round(getdate('三、住宿业', '应交增值税'), 1) paragraph208.add_run('亿元,而去年同期为' if(round(getspeed(), 1) > 0): paragraph208.add_run('同比增长') else: paragraph208.add_run('同比下降') paragraph208.add_run(str(round(getspeed('三、住宿业', '应交增值税'), 1) paragraph208.add_run('亿元;餐饮业企业应交增值税' paragraph208.add_run(str(round(getdate('四、餐饮业', '应交增值税'), 1) paragraph208.add_run('亿元,同比下降' if(round(getspeed(), 1) > 0): paragraph208.add_run('同比增长') else: paragraph208.add_run('同比下降') paragraph208.add_run(str(round(getspeed('四、餐饮业', '应交增值税'), 1) paragraph208.add_run('%。') ############### paragraph209 = document.add_paragraph('9、资产负债率。1-2季度,全市限额以上企业资产负债率' paragraph209.add_run(if (getdate('总计', '负债合计') > 0 and getdate('总计', '资产总计') > 0): round(getdate('总计', '负债合计') / getdate('总计', '资产总计') * 100, 1) else: "error") paragraph209.add_run('%,比去年同期提高' if(round(getspeed(), 1) > 0): paragraph209.add_run('同比增长') else: paragraph209.add_run('同比下降') paragraph209.add_run(str(if (getdate('总计', '资产总计') > 0 and getdate_lastyear('总计', '资产总计') > 0 and getdate('总计', '负债合计') > 0 and getdate_lastyear( '总计', '负债合计') > 0): round((getdate('总计', '负债合计') / getdate('总计', '资产总计') - getdate_lastyear('总计', '负债合计') / getdate_lastyear( '总计', '资产总计')) * 100, 1) else: "error") paragraph209.add_run('个百分点。其中批发业企业资产负债率' paragraph209.add_run(str(if (getdate('一、批发业', '资产总计') > 0 and getdate('一、批发业', '负债合计') > 0): round(getdate('一、批发业', '负债合计') / getdate('一、批发业', '资产总计') * 100, 1) else: "error") paragraph209.add_run('%,比去年同期提高' if(round(getspeed(), 1) > 0): paragraph209.add_run('同比增长') else: paragraph209.add_run('同比下降') paragraph209.add_run(str(if (getdate('一、批发业', '资产总计') > 0 and getdate_lastyear('一、批发业', '资产总计') > 0 and getdate('一、批发业', '负债合计') > 0 and getdate_lastyear( '一、批发业', '负债合计') > 0): round((getdate('一、批发业', '负债合计') / getdate('一、批发业', '资产总计') - getdate_lastyear('一、批发业', '负债合计') / getdate_lastyear( '一、批发业', '资产总计')) * 100, 1) else: "error") paragraph209.add_run('个百分点;零售业企业资产负债率' paragraph209.add_run(str(if (getdate('二、零售业', '资产总计') > 0 and getdate('二、零售业', '负债合计') > 0): round(getdate('二、零售业', '负债合计') / getdate('二、零售业', '资产总计') * 100, 1) else: "error") paragraph209.add_run('%,比去年同期提高' if(round(getspeed(), 1) > 0): paragraph209.add_run('同比增长') else: paragraph209.add_run('同比下降') paragraph209.add_run(str(if (getdate('二、零售业', '资产总计') > 0 and getdate_lastyear('二、零售业', '资产总计') > 0 and getdate('二、零售业', '负债合计') > 0 and getdate_lastyear( '二、零售业', '负债合计') > 0): round((getdate('二、零售业', '负债合计') / getdate('二、零售业', '资产总计') - getdate_lastyear('二、零售业', '负债合计') / getdate_lastyear( '二、零售业', '资产总计')) * 100, 1) else: "error") paragraph209.add_run('个百分点;住宿业企业资产负债率' paragraph209.add_run(str(if (getdate('三、住宿业', '资产总计') > 0 and getdate('三、住宿业', '负债合计') > 0): round(getdate('三、住宿业', '负债合计') / getdate('三、住宿业', '资产总计') * 100, 1) else: "error") paragraph209.add_run('%,比去年同期下降' if(round(getspeed(), 1) > 0): paragraph209.add_run('同比增长') else: paragraph209.add_run('同比下降') paragraph209.add_run(str(if (getdate('三、住宿业', '资产总计') > 0 and getdate_lastyear('三、住宿业', '资产总计') > 0 and getdate('三、住宿业', '负债合计') > 0 and getdate_lastyear( '三、住宿业', '负债合计') > 0): print(round((getdate('三、住宿业', '负债合计') / getdate('三、住宿业', '资产总计') - getdate_lastyear('三、住宿业', '负债合计') / getdate_lastyear( '三、住宿业', '资产总计')) * 100, 1)); else: print("error") paragraph209.add_run('个百分点;餐饮业企业资产负债率' paragraph209.add_run(str(if (getdate('四、餐饮业', '资产总计') > 0 and getdate('四、餐饮业', '负债合计') > 0): print(round(getdate('四、餐饮业', '负债合计') / getdate('四、餐饮业', '资产总计') * 100, 1)); else: print("error") paragraph209.add_run('%,比去年同期提高' if(round(getspeed(), 1) > 0): paragraph209.add_run('同比增长') else: paragraph209.add_run('同比下降') paragraph209.add_run(str(if (getdate('四、餐饮业', '资产总计') > 0 and getdate_lastyear('四、餐饮业', '资产总计') > 0 and getdate('四、餐饮业', '负债合计') > 0 and getdate_lastyear( '四、餐饮业', '负债合计') > 0): round((getdate('四、餐饮业', '负债合计') / getdate('四、餐饮业', '资产总计') - getdate_lastyear('四、餐饮业', '负债合计') / getdate_lastyear( '四、餐饮业', '资产总计')) * 100, 1) else: "error") paragraph209.add_run('个百分点。') ####################### paragraph210 = document.add_paragraph('10、毛利率。1-2季度,全市限额以上企业毛利率' paragraph210.add_run(str(if (getdate('总计', '营业收入') > 0 and getdate('总计', '营业成本') > 0): paragraph210.add_run('%,比去年同期减少' paragraph210.add_run(str( round((1 - getdate('总计', '营业成本') / getdate('总计', '营业收入')) * 100, 1) else: "error") paragraph210.add_run('个百分点。其中批发业企业毛利率' paragraph210.add_run(str( if (getdate_lastyear('总计', '营业收入') > 0 and getdate('总计', '营业收入') > 0 and getdate_lastyear('总计', '营业成本') > 0 and getdate( '总计', '营业成本') > 0): round((getdate_lastyear('总计', '营业成本') / getdate_lastyear('总计', '营业收入') - getdate('总计', '营业成本') / getdate( '总计', '营业收入')) * 100, 1) else: "error") if (getdate('一、批发业', '营业收入') > 0 and getdate('一、批发业', '营业成本') > 0): round((1 - getdate('一、批发业', '营业成本') / getdate('一、批发业', '营业收入')) * 100, 1) else: "error") paragraph210.add_run('%,比去年同期减少' if(round(getspeed(), 1) > 0): paragraph210.add_run('同比增长') else: paragraph210.add_run('同比下降') paragraph210.add_run(str( if (getdate_lastyear('一、批发业', '营业收入') > 0 and getdate('一、批发业', '营业收入') > 0 and getdate_lastyear('一、批发业', '营业成本') > 0 and getdate( '一、批发业', '营业成本') > 0): round((getdate_lastyear('一、批发业', '营业成本') / getdate_lastyear('一、批发业', '营业收入') - getdate('一、批发业', '营业成本') / getdate( '一、批发业', '营业收入')) * 100, 1) else: "error") paragraph210.add_run('个百分点;零售业企业毛利率' paragraph210.add_run(str( if (getdate('二、零售业', '营业收入') > 0 and getdate('二、零售业', '营业成本') > 0): round((1 - getdate('二、零售业', '营业成本') / getdate('二、零售业', '营业收入')) * 100, 1) else: "error") paragraph210.add_run('%,比上年同期减少' if(round(getspeed(), 1) > 0): paragraph210.add_run('同比增长') else: paragraph210.add_run('同比下降') paragraph210.add_run(str( if (getdate_lastyear('二、零售业', '营业收入') > 0 and getdate('二、零售业', '营业收入') > 0 and getdate_lastyear('二、零售业', '营业成本') > 0 and getdate( '二、零售业', '营业成本') > 0): round((getdate_lastyear('二、零售业', '营业成本') / getdate_lastyear('二、零售业', '营业收入') - getdate('二、零售业', '营业成本') / getdate( '二、零售业', '营业收入')) * 100, 1) else: "error") paragraph210.add_run('个百分点;住宿业企业毛利率' paragraph210.add_run(str( if (getdate('三、住宿业', '营业收入') > 0 and getdate('三、住宿业', '营业收入') > 0): round((1 - getdate('三、住宿业', '营业成本') / getdate('三、住宿业', '营业收入')) * 100, 1) else: "error") paragraph210.add_run('%,比上年同期减少' if(round(getspeed(), 1) > 0): paragraph210.add_run('同比增长') else: paragraph210.add_run('同比下降') paragraph210.add_run(str( if (getdate_lastyear('三、住宿业', '营业收入') > 0 and getdate('三、住宿业', '营业收入') > 0 and getdate_lastyear('三、住宿业', '营业成本') > 0 and getdate( '三、住宿业', '营业成本') > 0): round((getdate_lastyear('三、住宿业', '营业成本') / getdate_lastyear('三、住宿业', '营业收入') - getdate('三、住宿业', '营业成本') / getdate( '三、住宿业', '营业收入')) * 100, 1) else: "error") paragraph210.add_run('个百分点;餐饮业企业毛利率' paragraph210.add_run(str(if (getdate('四、餐饮业', '营业收入') > 0 and getdate('四、餐饮业', '营业成本') > 0): round((1 - getdate('四、餐饮业', '营业成本') / getdate('四、餐饮业', '营业收入')) * 100, 1) else: "error") paragraph210.add_run('%,比上年同期减少' if(round(getspeed(), 1) > 0): paragraph210.add_run('同比增长') else: paragraph210.add_run('同比下降') paragraph210.add_run(str( if (getdate_lastyear('四、餐饮业', '营业收入') > 0 and getdate('四、餐饮业', '营业收入') > 0 and getdate_lastyear('四、餐饮业', '营业成本') > 0 and getdate( '四、餐饮业', '营业成本') > 0): round((getdate_lastyear('四、餐饮业', '营业成本') / getdate_lastyear('四、餐饮业', '营业收入') - getdate('四、餐饮业', '营业成本') / getdate( '四、餐饮业', '营业收入')) * 100, 1) else: "error") paragraph210.add_run('个百分点。') ################# paragraph211 = document.add_paragraph('11、营业收入户均值。1-2季度,全市限额以上企业中批发业营业收入户均值' paragraph211.add_run(str(if (getdate('一、批发业', '企业数') > 0): round(getdate('一、批发业', '营业收入') / getdate('一、批发业', '企业数') * 10000, 1) else: "error") paragraph211.add_run('亿元;零售业企业营业收入户均值' paragraph211.add_run(str( if (getdate('二、零售业', '企业数') > 0): round(getdate('二、零售业', '营业收入') / getdate('二、零售业', '企业数') * 10000, 1) else: "error") paragraph211.add_run('亿元;住宿业企业营业收入户均值' paragraph211.add_run(str(if (getdate('三、住宿业', '企业数') > 0): round(getdate('三、住宿业', '营业收入') / getdate('三、住宿业', '企业数') * 10000, 1) else: "error") paragraph211.add_run('万元;餐饮业企业营业收入户均值' paragraph211.add_run(str( if (getdate('四、餐饮业', '企业数') > 0): round(getdate('四、餐饮业', '营业收入') / getdate('四、餐饮业', '企业数') * 10000, 1) else: "error") '营业收入人均值') paragraph211.add_run('万元。') paragraph212 = document.add_paragraph('12、营业收入人均值。1-2季度,全市限额以上企业中批发业企业营业收入人均值' paragraph212.add_run(str(if (getdate('一、批发业', '从业人员平均人数(人)') > 0): round(getdate('一、批发业', '营业收入') / getdate('一、批发业', '从业人员平均人数(人)') * 10000, 1) else: "error") paragraph212.add_run('万元;零售业企业营业收入人均值' 'if (getdate('二、零售业', '从业人员平均人数(人)') > 0): round(getdate('二、零售业', '营业收入') / getdate('二、零售业', '从业人员平均人数(人)') * 10000, 1) else: "error")' '万元;住宿业企业营业收入人均值' if (getdate('三、住宿业', '从业人员平均人数(人)') > 0): round(getdate('三、住宿业', '营业收入') / getdate('三、住宿业', '从业人员平均人数(人)') * 10000, 1) else: "error") '万元;餐饮业营业收入人均值' if (getdate('四、餐饮业', '从业人员平均人数(人)') > 0): round(getdate('四、餐饮业', '营业收入') / getdate('四、餐饮业', '从业人员平均人数(人)') * 10000, 1) else: "error") '万元。') ''' document.save('财务季报评估报告.docx')
财务季报评估报表数据提取+自动撰写2.4
Supongo que te gusta
Origin blog.csdn.net/jidawanghao/article/details/118795338
Recomendado
Clasificación