fixed warnings of excelexporters in API
parent
8fbf155960
commit
7270b1cdbb
|
@ -1,7 +1,7 @@
|
||||||
import base64
|
import base64
|
||||||
import uuid
|
import uuid
|
||||||
import os
|
import os
|
||||||
from openpyxl.styles import PatternFill, Border, Side, Alignment, Protection, Font
|
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
||||||
from openpyxl.drawing.image import Image
|
from openpyxl.drawing.image import Image
|
||||||
from openpyxl import Workbook
|
from openpyxl import Workbook
|
||||||
|
|
||||||
|
@ -103,12 +103,6 @@ def generate_excel(report, space_name, reporting_start_datetime_local, reporting
|
||||||
wrap_text=True,
|
wrap_text=True,
|
||||||
shrink_to_fit=False,
|
shrink_to_fit=False,
|
||||||
indent=0)
|
indent=0)
|
||||||
c_r_alignment = Alignment(vertical='bottom',
|
|
||||||
horizontal='center',
|
|
||||||
text_rotation=0,
|
|
||||||
wrap_text=True,
|
|
||||||
shrink_to_fit=False,
|
|
||||||
indent=0)
|
|
||||||
|
|
||||||
# Img
|
# Img
|
||||||
img = Image("excelexporters/myems.png")
|
img = Image("excelexporters/myems.png")
|
||||||
|
|
|
@ -2,11 +2,7 @@ import base64
|
||||||
import uuid
|
import uuid
|
||||||
import os
|
import os
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
from openpyxl.chart import (
|
from openpyxl.chart import PieChart, LineChart, Reference
|
||||||
PieChart,
|
|
||||||
LineChart,
|
|
||||||
Reference,
|
|
||||||
)
|
|
||||||
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
||||||
from openpyxl.drawing.image import Image
|
from openpyxl.drawing.image import Image
|
||||||
from openpyxl import Workbook
|
from openpyxl import Workbook
|
||||||
|
@ -117,18 +113,11 @@ def generate_excel(report,
|
||||||
wrap_text=True,
|
wrap_text=True,
|
||||||
shrink_to_fit=False,
|
shrink_to_fit=False,
|
||||||
indent=0)
|
indent=0)
|
||||||
c_r_alignment = Alignment(vertical='bottom',
|
|
||||||
horizontal='center',
|
|
||||||
text_rotation=0,
|
|
||||||
wrap_text=True,
|
|
||||||
shrink_to_fit=False,
|
|
||||||
indent=0)
|
|
||||||
|
|
||||||
# Img
|
# Img
|
||||||
img = Image("excelexporters/myems.png")
|
img = Image("excelexporters/myems.png")
|
||||||
img.width = img.width * 0.85
|
img.width = img.width * 0.85
|
||||||
img.height = img.height * 0.85
|
img.height = img.height * 0.85
|
||||||
# img = Image("myems.png")
|
|
||||||
ws.add_image(img, 'B1')
|
ws.add_image(img, 'B1')
|
||||||
|
|
||||||
# Title
|
# Title
|
||||||
|
@ -165,8 +154,6 @@ def generate_excel(report,
|
||||||
|
|
||||||
return filename
|
return filename
|
||||||
|
|
||||||
#################################################
|
|
||||||
|
|
||||||
reporting_period_data = report['reporting_period']
|
reporting_period_data = report['reporting_period']
|
||||||
|
|
||||||
has_energy_data_flag = True
|
has_energy_data_flag = True
|
||||||
|
@ -239,8 +226,6 @@ def generate_excel(report,
|
||||||
for i in range(6, 9 + 1):
|
for i in range(6, 9 + 1):
|
||||||
ws.row_dimensions[i].height = 0.1
|
ws.row_dimensions[i].height = 0.1
|
||||||
|
|
||||||
#################################################
|
|
||||||
|
|
||||||
has_ele_peak_flag = True
|
has_ele_peak_flag = True
|
||||||
if "toppeaks" not in reporting_period_data.keys() or \
|
if "toppeaks" not in reporting_period_data.keys() or \
|
||||||
reporting_period_data['toppeaks'] is None or \
|
reporting_period_data['toppeaks'] is None or \
|
||||||
|
|
|
@ -1,12 +1,7 @@
|
||||||
import base64
|
import base64
|
||||||
import uuid
|
import uuid
|
||||||
import os
|
import os
|
||||||
from openpyxl.chart import (
|
from openpyxl.chart import LineChart, Reference
|
||||||
PieChart,
|
|
||||||
LineChart,
|
|
||||||
BarChart,
|
|
||||||
Reference,
|
|
||||||
)
|
|
||||||
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
||||||
from openpyxl.drawing.image import Image
|
from openpyxl.drawing.image import Image
|
||||||
from openpyxl import Workbook
|
from openpyxl import Workbook
|
||||||
|
|
|
@ -1,12 +1,7 @@
|
||||||
import base64
|
import base64
|
||||||
import uuid
|
import uuid
|
||||||
import os
|
import os
|
||||||
from openpyxl.chart import (
|
from openpyxl.chart import PieChart, LineChart, Reference
|
||||||
PieChart,
|
|
||||||
LineChart,
|
|
||||||
BarChart,
|
|
||||||
Reference,
|
|
||||||
)
|
|
||||||
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
||||||
from openpyxl.drawing.image import Image
|
from openpyxl.drawing.image import Image
|
||||||
from openpyxl import Workbook
|
from openpyxl import Workbook
|
||||||
|
|
|
@ -1,11 +1,7 @@
|
||||||
import base64
|
import base64
|
||||||
import uuid
|
import uuid
|
||||||
import os
|
import os
|
||||||
from openpyxl.chart import (
|
from openpyxl.chart import PieChart, LineChart, Reference
|
||||||
PieChart,
|
|
||||||
LineChart,
|
|
||||||
Reference,
|
|
||||||
)
|
|
||||||
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
||||||
from openpyxl.drawing.image import Image
|
from openpyxl.drawing.image import Image
|
||||||
from openpyxl import Workbook
|
from openpyxl import Workbook
|
||||||
|
|
|
@ -2,12 +2,7 @@ import base64
|
||||||
import uuid
|
import uuid
|
||||||
import os
|
import os
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
|
from openpyxl.chart import PieChart, LineChart, Reference
|
||||||
from openpyxl.chart import (
|
|
||||||
PieChart,
|
|
||||||
LineChart,
|
|
||||||
Reference,
|
|
||||||
)
|
|
||||||
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
||||||
from openpyxl.drawing.image import Image
|
from openpyxl.drawing.image import Image
|
||||||
from openpyxl import Workbook
|
from openpyxl import Workbook
|
||||||
|
|
|
@ -1,10 +1,7 @@
|
||||||
import base64
|
import base64
|
||||||
import uuid
|
import uuid
|
||||||
import os
|
import os
|
||||||
from openpyxl.chart import (
|
from openpyxl.chart import LineChart, Reference
|
||||||
LineChart,
|
|
||||||
Reference,
|
|
||||||
)
|
|
||||||
from openpyxl.chart.label import DataLabelList
|
from openpyxl.chart.label import DataLabelList
|
||||||
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
||||||
from openpyxl.drawing.image import Image
|
from openpyxl.drawing.image import Image
|
||||||
|
@ -85,7 +82,6 @@ def generate_excel(report,
|
||||||
# Font
|
# Font
|
||||||
name_font = Font(name='Constantia', size=15, bold=True)
|
name_font = Font(name='Constantia', size=15, bold=True)
|
||||||
title_font = Font(name='宋体', size=15, bold=True)
|
title_font = Font(name='宋体', size=15, bold=True)
|
||||||
# data_font = Font(name='Franklin Gothic Book', size=11)
|
|
||||||
|
|
||||||
table_fill = PatternFill(fill_type='solid', fgColor='1F497D')
|
table_fill = PatternFill(fill_type='solid', fgColor='1F497D')
|
||||||
f_border = Border(left=Side(border_style='medium', color='00000000'),
|
f_border = Border(left=Side(border_style='medium', color='00000000'),
|
||||||
|
@ -162,98 +158,93 @@ def generate_excel(report,
|
||||||
####################################################################################################################
|
####################################################################################################################
|
||||||
reporting_period_data = report['reporting_period']
|
reporting_period_data = report['reporting_period']
|
||||||
|
|
||||||
has_energy_data_flag = True
|
|
||||||
|
|
||||||
if "names" not in reporting_period_data.keys() or \
|
if "names" not in reporting_period_data.keys() or \
|
||||||
reporting_period_data['names'] is None or \
|
reporting_period_data['names'] is None or \
|
||||||
len(reporting_period_data['names']) == 0:
|
len(reporting_period_data['names']) == 0:
|
||||||
has_energy_data_flag = False
|
|
||||||
|
|
||||||
filename = str(uuid.uuid4()) + '.xlsx'
|
filename = str(uuid.uuid4()) + '.xlsx'
|
||||||
wb.save(filename)
|
wb.save(filename)
|
||||||
|
|
||||||
return filename
|
return filename
|
||||||
|
|
||||||
if has_energy_data_flag:
|
ws['B6'].font = title_font
|
||||||
ws['B6'].font = title_font
|
ws['B6'] = name + ' 负荷分析'
|
||||||
ws['B6'] = name + ' 负荷分析'
|
|
||||||
|
|
||||||
category = reporting_period_data['names']
|
category = reporting_period_data['names']
|
||||||
|
|
||||||
# table_title
|
# table_title
|
||||||
ws['B7'].fill = table_fill
|
ws['B7'].fill = table_fill
|
||||||
ws['B7'].font = title_font
|
ws['B7'].font = title_font
|
||||||
ws['B7'].alignment = c_c_alignment
|
ws['B7'].alignment = c_c_alignment
|
||||||
ws['B7'] = '报告期'
|
ws['B7'] = '报告期'
|
||||||
ws['B7'].border = f_border
|
ws['B7'].border = f_border
|
||||||
|
|
||||||
ws['C7'].font = title_font
|
ws['C7'].font = title_font
|
||||||
ws['C7'].alignment = c_c_alignment
|
ws['C7'].alignment = c_c_alignment
|
||||||
ws['C7'] = '平均负荷'
|
ws['C7'] = '平均负荷'
|
||||||
ws['C7'].border = f_border
|
ws['C7'].border = f_border
|
||||||
|
|
||||||
ws['D7'].font = title_font
|
ws['D7'].font = title_font
|
||||||
ws['D7'].alignment = c_c_alignment
|
ws['D7'].alignment = c_c_alignment
|
||||||
ws['D7'] = '最大负荷'
|
ws['D7'] = '最大负荷'
|
||||||
ws['D7'].border = f_border
|
ws['D7'].border = f_border
|
||||||
|
|
||||||
ws['E7'].font = title_font
|
ws['E7'].font = title_font
|
||||||
ws['E7'].alignment = c_c_alignment
|
ws['E7'].alignment = c_c_alignment
|
||||||
ws['E7'] = '负荷系数'
|
ws['E7'] = '负荷系数'
|
||||||
ws['E7'].border = f_border
|
ws['E7'].border = f_border
|
||||||
|
|
||||||
# table_data
|
# table_data
|
||||||
|
|
||||||
for i, value in enumerate(category):
|
for i, value in enumerate(category):
|
||||||
row = i * 2 + 8
|
row = i * 2 + 8
|
||||||
ws['B' + str(row)].font = name_font
|
ws['B' + str(row)].font = name_font
|
||||||
ws['B' + str(row)].alignment = c_c_alignment
|
ws['B' + str(row)].alignment = c_c_alignment
|
||||||
ws['B' + str(row)] = reporting_period_data['names'][i] + " (" + reporting_period_data['units'][i] + "/H )"
|
ws['B' + str(row)] = reporting_period_data['names'][i] + " (" + reporting_period_data['units'][i] + "/H )"
|
||||||
ws['B' + str(row)].border = f_border
|
ws['B' + str(row)].border = f_border
|
||||||
|
|
||||||
ws['B' + str(row + 1)].font = name_font
|
ws['B' + str(row + 1)].font = name_font
|
||||||
ws['B' + str(row + 1)].alignment = c_c_alignment
|
ws['B' + str(row + 1)].alignment = c_c_alignment
|
||||||
ws['B' + str(row + 1)] = "环比"
|
ws['B' + str(row + 1)] = "环比"
|
||||||
ws['B' + str(row + 1)].border = f_border
|
ws['B' + str(row + 1)].border = f_border
|
||||||
|
|
||||||
ws['C' + str(row)].font = name_font
|
ws['C' + str(row)].font = name_font
|
||||||
ws['C' + str(row)].alignment = c_c_alignment
|
ws['C' + str(row)].alignment = c_c_alignment
|
||||||
ws['C' + str(row)] = round(reporting_period_data['averages'][i], 2) \
|
ws['C' + str(row)] = round(reporting_period_data['averages'][i], 2) \
|
||||||
if reporting_period_data['averages'][i] is not None else ''
|
if reporting_period_data['averages'][i] is not None else ''
|
||||||
ws['C' + str(row)].border = f_border
|
ws['C' + str(row)].border = f_border
|
||||||
ws['C' + str(row)].number_format = '0.00'
|
ws['C' + str(row)].number_format = '0.00'
|
||||||
|
|
||||||
ws['C' + str(row + 1)].font = name_font
|
ws['C' + str(row + 1)].font = name_font
|
||||||
ws['C' + str(row + 1)].alignment = c_c_alignment
|
ws['C' + str(row + 1)].alignment = c_c_alignment
|
||||||
ws['C' + str(row + 1)] = str(round(reporting_period_data['averages_increment_rate'][i] * 100, 2)) + "%" \
|
ws['C' + str(row + 1)] = str(round(reporting_period_data['averages_increment_rate'][i] * 100, 2)) + "%" \
|
||||||
if reporting_period_data['averages_increment_rate'][i] is not None else '0.00%'
|
if reporting_period_data['averages_increment_rate'][i] is not None else '0.00%'
|
||||||
ws['C' + str(row + 1)].border = f_border
|
ws['C' + str(row + 1)].border = f_border
|
||||||
|
|
||||||
ws['D' + str(row)].font = name_font
|
ws['D' + str(row)].font = name_font
|
||||||
ws['D' + str(row)].alignment = c_c_alignment
|
ws['D' + str(row)].alignment = c_c_alignment
|
||||||
ws['D' + str(row)] = round(reporting_period_data['maximums'][i], 2) \
|
ws['D' + str(row)] = round(reporting_period_data['maximums'][i], 2) \
|
||||||
if reporting_period_data['maximums'][i] is not None else ''
|
if reporting_period_data['maximums'][i] is not None else ''
|
||||||
ws['D' + str(row)].border = f_border
|
ws['D' + str(row)].border = f_border
|
||||||
ws['D' + str(row)].number_format = '0.00'
|
ws['D' + str(row)].number_format = '0.00'
|
||||||
|
|
||||||
ws['D' + str(row + 1)].font = name_font
|
ws['D' + str(row + 1)].font = name_font
|
||||||
ws['D' + str(row + 1)].alignment = c_c_alignment
|
ws['D' + str(row + 1)].alignment = c_c_alignment
|
||||||
ws['D' + str(row + 1)] = str(round(reporting_period_data['maximums_increment_rate'][i] * 100, 2)) + "%" \
|
ws['D' + str(row + 1)] = str(round(reporting_period_data['maximums_increment_rate'][i] * 100, 2)) + "%" \
|
||||||
if reporting_period_data['maximums_increment_rate'][i] is not None else '0.00%'
|
if reporting_period_data['maximums_increment_rate'][i] is not None else '0.00%'
|
||||||
ws['D' + str(row + 1)].border = f_border
|
ws['D' + str(row + 1)].border = f_border
|
||||||
|
|
||||||
ws['E' + str(row)].font = name_font
|
ws['E' + str(row)].font = name_font
|
||||||
ws['E' + str(row)].alignment = c_c_alignment
|
ws['E' + str(row)].alignment = c_c_alignment
|
||||||
ws['E' + str(row)] = round(reporting_period_data['factors'][i], 2) \
|
ws['E' + str(row)] = round(reporting_period_data['factors'][i], 2) \
|
||||||
if reporting_period_data['factors'][i] is not None else ''
|
if reporting_period_data['factors'][i] is not None else ''
|
||||||
ws['E' + str(row)].border = f_border
|
ws['E' + str(row)].border = f_border
|
||||||
ws['E' + str(row)].number_format = '0.00'
|
ws['E' + str(row)].number_format = '0.00'
|
||||||
|
|
||||||
ws['E' + str(row + 1)].font = name_font
|
ws['E' + str(row + 1)].font = name_font
|
||||||
ws['E' + str(row + 1)].alignment = c_c_alignment
|
ws['E' + str(row + 1)].alignment = c_c_alignment
|
||||||
ws['E' + str(row + 1)] = str(round(reporting_period_data['factors_increment_rate'][i] * 100, 2)) + "%" \
|
ws['E' + str(row + 1)] = str(round(reporting_period_data['factors_increment_rate'][i] * 100, 2)) + "%" \
|
||||||
if reporting_period_data['factors_increment_rate'][i] is not None else '0.00%'
|
if reporting_period_data['factors_increment_rate'][i] is not None else '0.00%'
|
||||||
ws['E' + str(row + 1)].border = f_border
|
ws['E' + str(row + 1)].border = f_border
|
||||||
|
|
||||||
####################################################################################################################
|
####################################################################################################################
|
||||||
# Third: 详细数据
|
# Third: 详细数据
|
||||||
|
|
|
@ -1,12 +1,7 @@
|
||||||
import base64
|
import base64
|
||||||
import uuid
|
import uuid
|
||||||
import os
|
import os
|
||||||
from openpyxl.chart import (
|
from openpyxl.chart import LineChart, Reference
|
||||||
PieChart,
|
|
||||||
LineChart,
|
|
||||||
BarChart,
|
|
||||||
Reference,
|
|
||||||
)
|
|
||||||
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
||||||
from openpyxl.drawing.image import Image
|
from openpyxl.drawing.image import Image
|
||||||
from openpyxl import Workbook
|
from openpyxl import Workbook
|
||||||
|
|
|
@ -2,13 +2,7 @@ import base64
|
||||||
import uuid
|
import uuid
|
||||||
import os
|
import os
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
|
from openpyxl.chart import PieChart, LineChart, Reference
|
||||||
from openpyxl.chart import (
|
|
||||||
PieChart,
|
|
||||||
LineChart,
|
|
||||||
BarChart,
|
|
||||||
Reference,
|
|
||||||
)
|
|
||||||
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
||||||
from openpyxl.drawing.image import Image
|
from openpyxl.drawing.image import Image
|
||||||
from openpyxl import Workbook
|
from openpyxl import Workbook
|
||||||
|
|
|
@ -1,10 +1,7 @@
|
||||||
import base64
|
import base64
|
||||||
import uuid
|
import uuid
|
||||||
import os
|
import os
|
||||||
from openpyxl.chart import (
|
from openpyxl.chart import LineChart, Reference
|
||||||
LineChart,
|
|
||||||
Reference,
|
|
||||||
)
|
|
||||||
from openpyxl.chart.label import DataLabelList
|
from openpyxl.chart.label import DataLabelList
|
||||||
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
||||||
from openpyxl.drawing.image import Image
|
from openpyxl.drawing.image import Image
|
||||||
|
@ -162,152 +159,146 @@ def generate_excel(report,
|
||||||
####################################################################################################################
|
####################################################################################################################
|
||||||
reporting_period_data = report['reporting_period']
|
reporting_period_data = report['reporting_period']
|
||||||
|
|
||||||
has_energy_data_flag = True
|
|
||||||
|
|
||||||
if "names" not in reporting_period_data.keys() or \
|
if "names" not in reporting_period_data.keys() or \
|
||||||
reporting_period_data['names'] is None or \
|
reporting_period_data['names'] is None or \
|
||||||
len(reporting_period_data['names']) == 0:
|
len(reporting_period_data['names']) == 0:
|
||||||
has_energy_data_flag = False
|
|
||||||
|
|
||||||
filename = str(uuid.uuid4()) + '.xlsx'
|
filename = str(uuid.uuid4()) + '.xlsx'
|
||||||
wb.save(filename)
|
wb.save(filename)
|
||||||
|
|
||||||
return filename
|
return filename
|
||||||
|
|
||||||
if has_energy_data_flag:
|
ws['B6'].font = title_font
|
||||||
ws['B6'].font = title_font
|
ws['B6'] = name + ' 统计分析'
|
||||||
ws['B6'] = name + ' 统计分析'
|
|
||||||
|
|
||||||
category = reporting_period_data['names']
|
category = reporting_period_data['names']
|
||||||
|
|
||||||
# table_title
|
# table_title
|
||||||
ws['B7'].fill = table_fill
|
ws['B7'].fill = table_fill
|
||||||
ws['B7'].font = title_font
|
ws['B7'].font = title_font
|
||||||
ws['B7'].alignment = c_c_alignment
|
ws['B7'].alignment = c_c_alignment
|
||||||
ws['B7'] = '报告期'
|
ws['B7'] = '报告期'
|
||||||
ws['B7'].border = f_border
|
ws['B7'].border = f_border
|
||||||
|
|
||||||
ws['C7'].font = title_font
|
ws['C7'].font = title_font
|
||||||
ws['C7'].alignment = c_c_alignment
|
ws['C7'].alignment = c_c_alignment
|
||||||
ws['C7'] = '算术平均数'
|
ws['C7'] = '算术平均数'
|
||||||
ws['C7'].border = f_border
|
ws['C7'].border = f_border
|
||||||
|
|
||||||
ws['D7'].font = title_font
|
ws['D7'].font = title_font
|
||||||
ws['D7'].alignment = c_c_alignment
|
ws['D7'].alignment = c_c_alignment
|
||||||
ws['D7'] = '中位数'
|
ws['D7'] = '中位数'
|
||||||
ws['D7'].border = f_border
|
ws['D7'].border = f_border
|
||||||
|
|
||||||
ws['E7'].font = title_font
|
ws['E7'].font = title_font
|
||||||
ws['E7'].alignment = c_c_alignment
|
ws['E7'].alignment = c_c_alignment
|
||||||
ws['E7'] = '最小值'
|
ws['E7'] = '最小值'
|
||||||
ws['E7'].border = f_border
|
ws['E7'].border = f_border
|
||||||
|
|
||||||
ws['F7'].font = title_font
|
ws['F7'].font = title_font
|
||||||
ws['F7'].alignment = c_c_alignment
|
ws['F7'].alignment = c_c_alignment
|
||||||
ws['F7'] = '最大值'
|
ws['F7'] = '最大值'
|
||||||
ws['F7'].border = f_border
|
ws['F7'].border = f_border
|
||||||
|
|
||||||
ws['G7'].font = title_font
|
ws['G7'].font = title_font
|
||||||
ws['G7'].alignment = c_c_alignment
|
ws['G7'].alignment = c_c_alignment
|
||||||
ws['G7'] = '样本标准差'
|
ws['G7'] = '样本标准差'
|
||||||
ws['G7'].border = f_border
|
ws['G7'].border = f_border
|
||||||
|
|
||||||
ws['H7'].font = title_font
|
ws['H7'].font = title_font
|
||||||
ws['H7'].alignment = c_c_alignment
|
ws['H7'].alignment = c_c_alignment
|
||||||
ws['H7'] = '样本方差'
|
ws['H7'] = '样本方差'
|
||||||
ws['H7'].border = f_border
|
ws['H7'].border = f_border
|
||||||
|
|
||||||
# table_data
|
# table_data
|
||||||
|
|
||||||
for i, value in enumerate(category):
|
for i, value in enumerate(category):
|
||||||
row = i * 2 + 8
|
row = i * 2 + 8
|
||||||
ws['B' + str(row)].font = name_font
|
ws['B' + str(row)].font = name_font
|
||||||
ws['B' + str(row)].alignment = c_c_alignment
|
ws['B' + str(row)].alignment = c_c_alignment
|
||||||
ws['B' + str(row)] = reporting_period_data['names'][i] + " (" + reporting_period_data['units'][i] + " )"
|
ws['B' + str(row)] = reporting_period_data['names'][i] + " (" + reporting_period_data['units'][i] + " )"
|
||||||
ws['B' + str(row)].border = f_border
|
ws['B' + str(row)].border = f_border
|
||||||
|
|
||||||
ws['B' + str(row + 1)].font = name_font
|
ws['B' + str(row + 1)].font = name_font
|
||||||
ws['B' + str(row + 1)].alignment = c_c_alignment
|
ws['B' + str(row + 1)].alignment = c_c_alignment
|
||||||
ws['B' + str(row + 1)] = "环比"
|
ws['B' + str(row + 1)] = "环比"
|
||||||
ws['B' + str(row + 1)].border = f_border
|
ws['B' + str(row + 1)].border = f_border
|
||||||
|
|
||||||
ws['C' + str(row)].font = name_font
|
ws['C' + str(row)].font = name_font
|
||||||
ws['C' + str(row)].alignment = c_c_alignment
|
ws['C' + str(row)].alignment = c_c_alignment
|
||||||
ws['C' + str(row)] = reporting_period_data['means'][i] \
|
ws['C' + str(row)] = reporting_period_data['means'][i] \
|
||||||
if reporting_period_data['means'][i] is not None else ''
|
if reporting_period_data['means'][i] is not None else ''
|
||||||
ws['C' + str(row)].border = f_border
|
ws['C' + str(row)].border = f_border
|
||||||
ws['C' + str(row)].number_format = '0.00'
|
ws['C' + str(row)].number_format = '0.00'
|
||||||
|
|
||||||
ws['C' + str(row + 1)].font = name_font
|
ws['C' + str(row + 1)].font = name_font
|
||||||
ws['C' + str(row + 1)].alignment = c_c_alignment
|
ws['C' + str(row + 1)].alignment = c_c_alignment
|
||||||
ws['C' + str(row + 1)] = str(round(reporting_period_data['means_increment_rate'][i] * 100, 2)) + "%" \
|
ws['C' + str(row + 1)] = str(round(reporting_period_data['means_increment_rate'][i] * 100, 2)) + "%" \
|
||||||
if reporting_period_data['means_increment_rate'][i] is not None else '0.00%'
|
if reporting_period_data['means_increment_rate'][i] is not None else '0.00%'
|
||||||
ws['C' + str(row + 1)].border = f_border
|
ws['C' + str(row + 1)].border = f_border
|
||||||
|
|
||||||
ws['D' + str(row)].font = name_font
|
ws['D' + str(row)].font = name_font
|
||||||
ws['D' + str(row)].alignment = c_c_alignment
|
ws['D' + str(row)].alignment = c_c_alignment
|
||||||
ws['D' + str(row)] = reporting_period_data['medians'][i] \
|
ws['D' + str(row)] = reporting_period_data['medians'][i] \
|
||||||
if reporting_period_data['medians'][i] is not None else ''
|
if reporting_period_data['medians'][i] is not None else ''
|
||||||
ws['D' + str(row)].border = f_border
|
ws['D' + str(row)].border = f_border
|
||||||
ws['D' + str(row)].number_format = '0.00'
|
ws['D' + str(row)].number_format = '0.00'
|
||||||
|
|
||||||
ws['D' + str(row + 1)].font = name_font
|
ws['D' + str(row + 1)].font = name_font
|
||||||
ws['D' + str(row + 1)].alignment = c_c_alignment
|
ws['D' + str(row + 1)].alignment = c_c_alignment
|
||||||
ws['D' + str(row + 1)] = str(round(reporting_period_data['medians_increment_rate'][i] * 100, 2)) + "%" \
|
ws['D' + str(row + 1)] = str(round(reporting_period_data['medians_increment_rate'][i] * 100, 2)) + "%" \
|
||||||
if reporting_period_data['medians_increment_rate'][i] is not None else '0.00%'
|
if reporting_period_data['medians_increment_rate'][i] is not None else '0.00%'
|
||||||
ws['D' + str(row + 1)].border = f_border
|
ws['D' + str(row + 1)].border = f_border
|
||||||
|
|
||||||
ws['E' + str(row)].font = name_font
|
ws['E' + str(row)].font = name_font
|
||||||
ws['E' + str(row)].alignment = c_c_alignment
|
ws['E' + str(row)].alignment = c_c_alignment
|
||||||
ws['E' + str(row)] = reporting_period_data['minimums'][i] \
|
ws['E' + str(row)] = reporting_period_data['minimums'][i] \
|
||||||
if reporting_period_data['minimums'][i] is not None else ''
|
if reporting_period_data['minimums'][i] is not None else ''
|
||||||
ws['E' + str(row)].border = f_border
|
ws['E' + str(row)].border = f_border
|
||||||
ws['E' + str(row)].number_format = '0.00'
|
ws['E' + str(row)].number_format = '0.00'
|
||||||
|
|
||||||
ws['E' + str(row + 1)].font = name_font
|
ws['E' + str(row + 1)].font = name_font
|
||||||
ws['E' + str(row + 1)].alignment = c_c_alignment
|
ws['E' + str(row + 1)].alignment = c_c_alignment
|
||||||
ws['E' + str(row + 1)] = str(round(reporting_period_data['minimums_increment_rate'][i] * 100, 2)) + "%" \
|
ws['E' + str(row + 1)] = str(round(reporting_period_data['minimums_increment_rate'][i] * 100, 2)) + "%" \
|
||||||
if reporting_period_data['minimums_increment_rate'][i] is not None else '0.00%'
|
if reporting_period_data['minimums_increment_rate'][i] is not None else '0.00%'
|
||||||
ws['E' + str(row + 1)].border = f_border
|
ws['E' + str(row + 1)].border = f_border
|
||||||
|
|
||||||
ws['F' + str(row)].font = name_font
|
ws['F' + str(row)].font = name_font
|
||||||
ws['F' + str(row)].alignment = c_c_alignment
|
ws['F' + str(row)].alignment = c_c_alignment
|
||||||
ws['F' + str(row)] = reporting_period_data['maximums'][i] \
|
ws['F' + str(row)] = reporting_period_data['maximums'][i] \
|
||||||
if reporting_period_data['maximums'][i] is not None else ''
|
if reporting_period_data['maximums'][i] is not None else ''
|
||||||
ws['F' + str(row)].border = f_border
|
ws['F' + str(row)].border = f_border
|
||||||
ws['F' + str(row)].number_format = '0.00'
|
ws['F' + str(row)].number_format = '0.00'
|
||||||
|
|
||||||
ws['F' + str(row + 1)].font = name_font
|
ws['F' + str(row + 1)].font = name_font
|
||||||
ws['F' + str(row + 1)].alignment = c_c_alignment
|
ws['F' + str(row + 1)].alignment = c_c_alignment
|
||||||
ws['F' + str(row + 1)] = str(round(reporting_period_data['maximums_increment_rate'][i] * 100, 2)) + "%" \
|
ws['F' + str(row + 1)] = str(round(reporting_period_data['maximums_increment_rate'][i] * 100, 2)) + "%" \
|
||||||
if reporting_period_data['maximums_increment_rate'][i] is not None else '0.00%'
|
if reporting_period_data['maximums_increment_rate'][i] is not None else '0.00%'
|
||||||
ws['F' + str(row + 1)].border = f_border
|
ws['F' + str(row + 1)].border = f_border
|
||||||
|
|
||||||
ws['G' + str(row)].font = name_font
|
ws['G' + str(row)].font = name_font
|
||||||
ws['G' + str(row)].alignment = c_c_alignment
|
ws['G' + str(row)].alignment = c_c_alignment
|
||||||
ws['G' + str(row)] = reporting_period_data['stdevs'][i] \
|
ws['G' + str(row)] = reporting_period_data['stdevs'][i] \
|
||||||
if reporting_period_data['stdevs'][i] is not None else ''
|
if reporting_period_data['stdevs'][i] is not None else ''
|
||||||
ws['G' + str(row)].border = f_border
|
ws['G' + str(row)].border = f_border
|
||||||
ws['G' + str(row)].number_format = '0.00'
|
ws['G' + str(row)].number_format = '0.00'
|
||||||
|
|
||||||
ws['G' + str(row + 1)].font = name_font
|
ws['G' + str(row + 1)].font = name_font
|
||||||
ws['G' + str(row + 1)].alignment = c_c_alignment
|
ws['G' + str(row + 1)].alignment = c_c_alignment
|
||||||
ws['G' + str(row + 1)] = str(round(reporting_period_data['stdevs_increment_rate'][i] * 100, 2)) + "%" \
|
ws['G' + str(row + 1)] = str(round(reporting_period_data['stdevs_increment_rate'][i] * 100, 2)) + "%" \
|
||||||
if reporting_period_data['stdevs_increment_rate'][i] is not None else '0.00%'
|
if reporting_period_data['stdevs_increment_rate'][i] is not None else '0.00%'
|
||||||
ws['G' + str(row + 1)].border = f_border
|
ws['G' + str(row + 1)].border = f_border
|
||||||
|
|
||||||
ws['H' + str(row)].font = name_font
|
ws['H' + str(row)].font = name_font
|
||||||
ws['H' + str(row)].alignment = c_c_alignment
|
ws['H' + str(row)].alignment = c_c_alignment
|
||||||
ws['H' + str(row)] = reporting_period_data['variances'][i] \
|
ws['H' + str(row)] = reporting_period_data['variances'][i] \
|
||||||
if reporting_period_data['variances'][i] is not None else ''
|
if reporting_period_data['variances'][i] is not None else ''
|
||||||
ws['H' + str(row)].border = f_border
|
ws['H' + str(row)].border = f_border
|
||||||
ws['H' + str(row)].number_format = '0.00'
|
ws['H' + str(row)].number_format = '0.00'
|
||||||
|
|
||||||
ws['H' + str(row + 1)].font = name_font
|
ws['H' + str(row + 1)].font = name_font
|
||||||
ws['H' + str(row + 1)].alignment = c_c_alignment
|
ws['H' + str(row + 1)].alignment = c_c_alignment
|
||||||
ws['H' + str(row + 1)] = str(round(reporting_period_data['variances_increment_rate'][i] * 100, 2)) + "%" \
|
ws['H' + str(row + 1)] = str(round(reporting_period_data['variances_increment_rate'][i] * 100, 2)) + "%" \
|
||||||
if reporting_period_data['variances_increment_rate'][i] is not None else '0.00%'
|
if reporting_period_data['variances_increment_rate'][i] is not None else '0.00%'
|
||||||
ws['H' + str(row + 1)].border = f_border
|
ws['H' + str(row + 1)].border = f_border
|
||||||
|
|
||||||
####################################################################################################################
|
####################################################################################################################
|
||||||
# Second: 详细数据
|
# Second: 详细数据
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import base64
|
import base64
|
||||||
import uuid
|
import uuid
|
||||||
import os
|
import os
|
||||||
from openpyxl.styles import PatternFill, Border, Side, Alignment, Protection, Font
|
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
||||||
from openpyxl.drawing.image import Image
|
from openpyxl.drawing.image import Image
|
||||||
from openpyxl import Workbook
|
from openpyxl import Workbook
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,7 @@
|
||||||
import base64
|
import base64
|
||||||
import uuid
|
import uuid
|
||||||
import os
|
import os
|
||||||
from openpyxl.chart import (
|
from openpyxl.chart import PieChart, LineChart, Reference
|
||||||
PieChart,
|
|
||||||
LineChart,
|
|
||||||
BarChart,
|
|
||||||
Reference,
|
|
||||||
)
|
|
||||||
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
||||||
from openpyxl.drawing.image import Image
|
from openpyxl.drawing.image import Image
|
||||||
from openpyxl import Workbook
|
from openpyxl import Workbook
|
||||||
|
@ -90,7 +85,6 @@ def generate_excel(report,
|
||||||
# Font
|
# Font
|
||||||
name_font = Font(name='Constantia', size=15, bold=True)
|
name_font = Font(name='Constantia', size=15, bold=True)
|
||||||
title_font = Font(name='宋体', size=15, bold=True)
|
title_font = Font(name='宋体', size=15, bold=True)
|
||||||
data_font = Font(name='Franklin Gothic Book', size=11)
|
|
||||||
|
|
||||||
table_fill = PatternFill(fill_type='solid', fgColor='1F497D')
|
table_fill = PatternFill(fill_type='solid', fgColor='1F497D')
|
||||||
f_border = Border(left=Side(border_style='medium', color='00000000'),
|
f_border = Border(left=Side(border_style='medium', color='00000000'),
|
||||||
|
@ -98,9 +92,7 @@ def generate_excel(report,
|
||||||
bottom=Side(border_style='medium', color='00000000'),
|
bottom=Side(border_style='medium', color='00000000'),
|
||||||
top=Side(border_style='medium', color='00000000')
|
top=Side(border_style='medium', color='00000000')
|
||||||
)
|
)
|
||||||
b_border = Border(
|
b_border = Border(bottom=Side(border_style='medium', color='00000000'),)
|
||||||
bottom=Side(border_style='medium', color='00000000'),
|
|
||||||
)
|
|
||||||
|
|
||||||
b_c_alignment = Alignment(vertical='bottom',
|
b_c_alignment = Alignment(vertical='bottom',
|
||||||
horizontal='center',
|
horizontal='center',
|
||||||
|
@ -445,7 +437,6 @@ def generate_excel(report,
|
||||||
for i in range(0, len(time)):
|
for i in range(0, len(time)):
|
||||||
col = 'B'
|
col = 'B'
|
||||||
row = str(table_row+1 + i)
|
row = str(table_row+1 + i)
|
||||||
# col = chr(ord('B') + i)
|
|
||||||
ws[col + row].font = title_font
|
ws[col + row].font = title_font
|
||||||
ws[col + row].alignment = c_c_alignment
|
ws[col + row].alignment = c_c_alignment
|
||||||
ws[col + row] = time[i]
|
ws[col + row] = time[i]
|
||||||
|
|
|
@ -1,12 +1,7 @@
|
||||||
import base64
|
import base64
|
||||||
import uuid
|
import uuid
|
||||||
import os
|
import os
|
||||||
from openpyxl.chart import (
|
from openpyxl.chart import LineChart, Reference
|
||||||
PieChart,
|
|
||||||
LineChart,
|
|
||||||
BarChart,
|
|
||||||
Reference,
|
|
||||||
)
|
|
||||||
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
||||||
from openpyxl.drawing.image import Image
|
from openpyxl.drawing.image import Image
|
||||||
from openpyxl import Workbook
|
from openpyxl import Workbook
|
||||||
|
@ -88,7 +83,6 @@ def generate_excel(report,
|
||||||
# Font
|
# Font
|
||||||
name_font = Font(name='Constantia', size=15, bold=True)
|
name_font = Font(name='Constantia', size=15, bold=True)
|
||||||
title_font = Font(name='宋体', size=15, bold=True)
|
title_font = Font(name='宋体', size=15, bold=True)
|
||||||
data_font = Font(name='Franklin Gothic Book', size=11)
|
|
||||||
|
|
||||||
table_fill = PatternFill(fill_type='solid', fgColor='1F497D')
|
table_fill = PatternFill(fill_type='solid', fgColor='1F497D')
|
||||||
f_border = Border(left=Side(border_style='medium', color='00000000'),
|
f_border = Border(left=Side(border_style='medium', color='00000000'),
|
||||||
|
@ -96,9 +90,7 @@ def generate_excel(report,
|
||||||
bottom=Side(border_style='medium', color='00000000'),
|
bottom=Side(border_style='medium', color='00000000'),
|
||||||
top=Side(border_style='medium', color='00000000')
|
top=Side(border_style='medium', color='00000000')
|
||||||
)
|
)
|
||||||
b_border = Border(
|
b_border = Border(bottom=Side(border_style='medium', color='00000000'),)
|
||||||
bottom=Side(border_style='medium', color='00000000'),
|
|
||||||
)
|
|
||||||
|
|
||||||
b_c_alignment = Alignment(vertical='bottom',
|
b_c_alignment = Alignment(vertical='bottom',
|
||||||
horizontal='center',
|
horizontal='center',
|
||||||
|
@ -118,12 +110,6 @@ def generate_excel(report,
|
||||||
wrap_text=True,
|
wrap_text=True,
|
||||||
shrink_to_fit=False,
|
shrink_to_fit=False,
|
||||||
indent=0)
|
indent=0)
|
||||||
c_r_alignment = Alignment(vertical='bottom',
|
|
||||||
horizontal='center',
|
|
||||||
text_rotation=0,
|
|
||||||
wrap_text=True,
|
|
||||||
shrink_to_fit=False,
|
|
||||||
indent=0)
|
|
||||||
# Img
|
# Img
|
||||||
img = Image("excelexporters/myems.png")
|
img = Image("excelexporters/myems.png")
|
||||||
img.width = img.width * 0.85
|
img.width = img.width * 0.85
|
||||||
|
|
|
@ -1,12 +1,7 @@
|
||||||
import base64
|
import base64
|
||||||
import uuid
|
import uuid
|
||||||
import os
|
import os
|
||||||
from openpyxl.chart import (
|
from openpyxl.chart import PieChart, LineChart, Reference
|
||||||
PieChart,
|
|
||||||
LineChart,
|
|
||||||
BarChart,
|
|
||||||
Reference,
|
|
||||||
)
|
|
||||||
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
||||||
from openpyxl.drawing.image import Image
|
from openpyxl.drawing.image import Image
|
||||||
from openpyxl import Workbook
|
from openpyxl import Workbook
|
||||||
|
@ -90,7 +85,6 @@ def generate_excel(report,
|
||||||
# Font
|
# Font
|
||||||
name_font = Font(name='Constantia', size=15, bold=True)
|
name_font = Font(name='Constantia', size=15, bold=True)
|
||||||
title_font = Font(name='宋体', size=15, bold=True)
|
title_font = Font(name='宋体', size=15, bold=True)
|
||||||
data_font = Font(name='Franklin Gothic Book', size=11)
|
|
||||||
|
|
||||||
table_fill = PatternFill(fill_type='solid', fgColor='1F497D')
|
table_fill = PatternFill(fill_type='solid', fgColor='1F497D')
|
||||||
f_border = Border(left=Side(border_style='medium', color='00000000'),
|
f_border = Border(left=Side(border_style='medium', color='00000000'),
|
||||||
|
@ -98,9 +92,7 @@ def generate_excel(report,
|
||||||
bottom=Side(border_style='medium', color='00000000'),
|
bottom=Side(border_style='medium', color='00000000'),
|
||||||
top=Side(border_style='medium', color='00000000')
|
top=Side(border_style='medium', color='00000000')
|
||||||
)
|
)
|
||||||
b_border = Border(
|
b_border = Border(bottom=Side(border_style='medium', color='00000000'), )
|
||||||
bottom=Side(border_style='medium', color='00000000'),
|
|
||||||
)
|
|
||||||
|
|
||||||
b_c_alignment = Alignment(vertical='bottom',
|
b_c_alignment = Alignment(vertical='bottom',
|
||||||
horizontal='center',
|
horizontal='center',
|
||||||
|
|
|
@ -1,12 +1,7 @@
|
||||||
import base64
|
import base64
|
||||||
import uuid
|
import uuid
|
||||||
import os
|
import os
|
||||||
from openpyxl.chart import (
|
from openpyxl.chart import PieChart, LineChart, Reference
|
||||||
PieChart,
|
|
||||||
LineChart,
|
|
||||||
BarChart,
|
|
||||||
Reference,
|
|
||||||
)
|
|
||||||
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
||||||
from openpyxl.drawing.image import Image
|
from openpyxl.drawing.image import Image
|
||||||
from openpyxl import Workbook
|
from openpyxl import Workbook
|
||||||
|
@ -95,9 +90,7 @@ def generate_excel(report,
|
||||||
bottom=Side(border_style='medium', color='00000000'),
|
bottom=Side(border_style='medium', color='00000000'),
|
||||||
top=Side(border_style='medium', color='00000000')
|
top=Side(border_style='medium', color='00000000')
|
||||||
)
|
)
|
||||||
b_border = Border(
|
b_border = Border(bottom=Side(border_style='medium', color='00000000'), )
|
||||||
bottom=Side(border_style='medium', color='00000000'),
|
|
||||||
)
|
|
||||||
|
|
||||||
b_c_alignment = Alignment(vertical='bottom',
|
b_c_alignment = Alignment(vertical='bottom',
|
||||||
horizontal='center',
|
horizontal='center',
|
||||||
|
|
|
@ -1,12 +1,7 @@
|
||||||
import base64
|
import base64
|
||||||
import uuid
|
import uuid
|
||||||
import os
|
import os
|
||||||
from openpyxl.chart import (
|
from openpyxl.chart import PieChart, LineChart, Reference
|
||||||
PieChart,
|
|
||||||
LineChart,
|
|
||||||
BarChart,
|
|
||||||
Reference,
|
|
||||||
)
|
|
||||||
from decimal import *
|
from decimal import *
|
||||||
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
||||||
from openpyxl.drawing.image import Image
|
from openpyxl.drawing.image import Image
|
||||||
|
@ -95,9 +90,7 @@ def generate_excel(report,
|
||||||
bottom=Side(border_style='medium', color='00000000'),
|
bottom=Side(border_style='medium', color='00000000'),
|
||||||
top=Side(border_style='medium', color='00000000')
|
top=Side(border_style='medium', color='00000000')
|
||||||
)
|
)
|
||||||
b_border = Border(
|
b_border = Border(bottom=Side(border_style='medium', color='00000000'), )
|
||||||
bottom=Side(border_style='medium', color='00000000'),
|
|
||||||
)
|
|
||||||
|
|
||||||
b_c_alignment = Alignment(vertical='bottom',
|
b_c_alignment = Alignment(vertical='bottom',
|
||||||
horizontal='center',
|
horizontal='center',
|
||||||
|
|
|
@ -1,10 +1,7 @@
|
||||||
import base64
|
import base64
|
||||||
import uuid
|
import uuid
|
||||||
import os
|
import os
|
||||||
from openpyxl.chart import (
|
from openpyxl.chart import LineChart, Reference
|
||||||
LineChart,
|
|
||||||
Reference,
|
|
||||||
)
|
|
||||||
from openpyxl.chart.label import DataLabelList
|
from openpyxl.chart.label import DataLabelList
|
||||||
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
||||||
from openpyxl.drawing.image import Image
|
from openpyxl.drawing.image import Image
|
||||||
|
@ -92,9 +89,7 @@ def generate_excel(report,
|
||||||
bottom=Side(border_style='medium', color='00000000'),
|
bottom=Side(border_style='medium', color='00000000'),
|
||||||
top=Side(border_style='medium', color='00000000')
|
top=Side(border_style='medium', color='00000000')
|
||||||
)
|
)
|
||||||
b_border = Border(
|
b_border = Border(bottom=Side(border_style='medium', color='00000000'), )
|
||||||
bottom=Side(border_style='medium', color='00000000'),
|
|
||||||
)
|
|
||||||
|
|
||||||
b_c_alignment = Alignment(vertical='bottom',
|
b_c_alignment = Alignment(vertical='bottom',
|
||||||
horizontal='center',
|
horizontal='center',
|
||||||
|
@ -161,98 +156,92 @@ def generate_excel(report,
|
||||||
####################################################################################################################
|
####################################################################################################################
|
||||||
reporting_period_data = report['reporting_period']
|
reporting_period_data = report['reporting_period']
|
||||||
|
|
||||||
has_energy_data_flag = True
|
|
||||||
|
|
||||||
if "names" not in reporting_period_data.keys() or \
|
if "names" not in reporting_period_data.keys() or \
|
||||||
reporting_period_data['names'] is None or \
|
reporting_period_data['names'] is None or \
|
||||||
len(reporting_period_data['names']) == 0:
|
len(reporting_period_data['names']) == 0:
|
||||||
has_energy_data_flag = False
|
|
||||||
|
|
||||||
filename = str(uuid.uuid4()) + '.xlsx'
|
filename = str(uuid.uuid4()) + '.xlsx'
|
||||||
wb.save(filename)
|
wb.save(filename)
|
||||||
|
|
||||||
return filename
|
return filename
|
||||||
|
|
||||||
if has_energy_data_flag:
|
ws['B6'].font = title_font
|
||||||
ws['B6'].font = title_font
|
ws['B6'] = name + ' 统计分析'
|
||||||
ws['B6'] = name + ' 统计分析'
|
|
||||||
|
|
||||||
category = reporting_period_data['names']
|
category = reporting_period_data['names']
|
||||||
|
|
||||||
# table_title
|
# table_title
|
||||||
ws['B7'].fill = table_fill
|
ws['B7'].fill = table_fill
|
||||||
ws['B7'].font = title_font
|
ws['B7'].font = title_font
|
||||||
ws['B7'].alignment = c_c_alignment
|
ws['B7'].alignment = c_c_alignment
|
||||||
ws['B7'] = '报告期'
|
ws['B7'] = '报告期'
|
||||||
ws['B7'].border = f_border
|
ws['B7'].border = f_border
|
||||||
|
|
||||||
ws['C7'].font = title_font
|
ws['C7'].font = title_font
|
||||||
ws['C7'].alignment = c_c_alignment
|
ws['C7'].alignment = c_c_alignment
|
||||||
ws['C7'] = '平均负荷'
|
ws['C7'] = '平均负荷'
|
||||||
ws['C7'].border = f_border
|
ws['C7'].border = f_border
|
||||||
|
|
||||||
ws['D7'].font = title_font
|
ws['D7'].font = title_font
|
||||||
ws['D7'].alignment = c_c_alignment
|
ws['D7'].alignment = c_c_alignment
|
||||||
ws['D7'] = '最大负荷'
|
ws['D7'] = '最大负荷'
|
||||||
ws['D7'].border = f_border
|
ws['D7'].border = f_border
|
||||||
|
|
||||||
ws['E7'].font = title_font
|
ws['E7'].font = title_font
|
||||||
ws['E7'].alignment = c_c_alignment
|
ws['E7'].alignment = c_c_alignment
|
||||||
ws['E7'] = '负荷系数'
|
ws['E7'] = '负荷系数'
|
||||||
ws['E7'].border = f_border
|
ws['E7'].border = f_border
|
||||||
|
|
||||||
# table_data
|
# table_data
|
||||||
|
|
||||||
for i, value in enumerate(category):
|
for i, value in enumerate(category):
|
||||||
row = i * 2 + 8
|
row = i * 2 + 8
|
||||||
ws['B' + str(row)].font = name_font
|
ws['B' + str(row)].font = name_font
|
||||||
ws['B' + str(row)].alignment = c_c_alignment
|
ws['B' + str(row)].alignment = c_c_alignment
|
||||||
ws['B' + str(row)] = reporting_period_data['names'][i] + " (" + reporting_period_data['units'][i] + "/H )"
|
ws['B' + str(row)] = reporting_period_data['names'][i] + " (" + reporting_period_data['units'][i] + "/H )"
|
||||||
ws['B' + str(row)].border = f_border
|
ws['B' + str(row)].border = f_border
|
||||||
|
|
||||||
ws['B' + str(row + 1)].font = name_font
|
ws['B' + str(row + 1)].font = name_font
|
||||||
ws['B' + str(row + 1)].alignment = c_c_alignment
|
ws['B' + str(row + 1)].alignment = c_c_alignment
|
||||||
ws['B' + str(row + 1)] = "环比"
|
ws['B' + str(row + 1)] = "环比"
|
||||||
ws['B' + str(row + 1)].border = f_border
|
ws['B' + str(row + 1)].border = f_border
|
||||||
|
|
||||||
ws['C' + str(row)].font = name_font
|
ws['C' + str(row)].font = name_font
|
||||||
ws['C' + str(row)].alignment = c_c_alignment
|
ws['C' + str(row)].alignment = c_c_alignment
|
||||||
ws['C' + str(row)] = round(reporting_period_data['averages'][i], 2) \
|
ws['C' + str(row)] = round(reporting_period_data['averages'][i], 2) \
|
||||||
if reporting_period_data['averages'][i] is not None else ''
|
if reporting_period_data['averages'][i] is not None else ''
|
||||||
ws['C' + str(row)].border = f_border
|
ws['C' + str(row)].border = f_border
|
||||||
ws['C' + str(row)].number_format = '0.00'
|
ws['C' + str(row)].number_format = '0.00'
|
||||||
|
|
||||||
ws['C' + str(row + 1)].font = name_font
|
ws['C' + str(row + 1)].font = name_font
|
||||||
ws['C' + str(row + 1)].alignment = c_c_alignment
|
ws['C' + str(row + 1)].alignment = c_c_alignment
|
||||||
ws['C' + str(row + 1)] = str(round(reporting_period_data['averages_increment_rate'][i] * 100, 2)) + "%" \
|
ws['C' + str(row + 1)] = str(round(reporting_period_data['averages_increment_rate'][i] * 100, 2)) + "%" \
|
||||||
if reporting_period_data['averages_increment_rate'][i] is not None else '0.00%'
|
if reporting_period_data['averages_increment_rate'][i] is not None else '0.00%'
|
||||||
ws['C' + str(row + 1)].border = f_border
|
ws['C' + str(row + 1)].border = f_border
|
||||||
|
|
||||||
ws['D' + str(row)].font = name_font
|
ws['D' + str(row)].font = name_font
|
||||||
ws['D' + str(row)].alignment = c_c_alignment
|
ws['D' + str(row)].alignment = c_c_alignment
|
||||||
ws['D' + str(row)] = round(reporting_period_data['maximums'][i], 2) \
|
ws['D' + str(row)] = round(reporting_period_data['maximums'][i], 2) \
|
||||||
if reporting_period_data['maximums'][i] is not None else ''
|
if reporting_period_data['maximums'][i] is not None else ''
|
||||||
ws['D' + str(row)].border = f_border
|
ws['D' + str(row)].border = f_border
|
||||||
ws['D' + str(row)].number_format = '0.00'
|
ws['D' + str(row)].number_format = '0.00'
|
||||||
|
|
||||||
ws['D' + str(row + 1)].font = name_font
|
ws['D' + str(row + 1)].font = name_font
|
||||||
ws['D' + str(row + 1)].alignment = c_c_alignment
|
ws['D' + str(row + 1)].alignment = c_c_alignment
|
||||||
ws['D' + str(row + 1)] = str(round(reporting_period_data['maximums_increment_rate'][i] * 100, 2)) + "%" \
|
ws['D' + str(row + 1)] = str(round(reporting_period_data['maximums_increment_rate'][i] * 100, 2)) + "%" \
|
||||||
if reporting_period_data['maximums_increment_rate'][i] is not None else '0.00%'
|
if reporting_period_data['maximums_increment_rate'][i] is not None else '0.00%'
|
||||||
ws['D' + str(row + 1)].border = f_border
|
ws['D' + str(row + 1)].border = f_border
|
||||||
|
|
||||||
ws['E' + str(row)].font = name_font
|
ws['E' + str(row)].font = name_font
|
||||||
ws['E' + str(row)].alignment = c_c_alignment
|
ws['E' + str(row)].alignment = c_c_alignment
|
||||||
ws['E' + str(row)] = round(reporting_period_data['factors'][i], 2) \
|
ws['E' + str(row)] = round(reporting_period_data['factors'][i], 2) \
|
||||||
if reporting_period_data['factors'][i] is not None else ''
|
if reporting_period_data['factors'][i] is not None else ''
|
||||||
ws['E' + str(row)].border = f_border
|
ws['E' + str(row)].border = f_border
|
||||||
ws['E' + str(row)].number_format = '0.00'
|
ws['E' + str(row)].number_format = '0.00'
|
||||||
|
|
||||||
ws['E' + str(row + 1)].font = name_font
|
ws['E' + str(row + 1)].font = name_font
|
||||||
ws['E' + str(row + 1)].alignment = c_c_alignment
|
ws['E' + str(row + 1)].alignment = c_c_alignment
|
||||||
ws['E' + str(row + 1)] = str(round(reporting_period_data['factors_increment_rate'][i] * 100, 2)) + "%" \
|
ws['E' + str(row + 1)] = str(round(reporting_period_data['factors_increment_rate'][i] * 100, 2)) + "%" \
|
||||||
if reporting_period_data['factors_increment_rate'][i] is not None else '0.00%'
|
if reporting_period_data['factors_increment_rate'][i] is not None else '0.00%'
|
||||||
ws['E' + str(row + 1)].border = f_border
|
ws['E' + str(row + 1)].border = f_border
|
||||||
|
|
||||||
####################################################################################################################
|
####################################################################################################################
|
||||||
# Third: 详细数据
|
# Third: 详细数据
|
||||||
|
|
|
@ -1,12 +1,7 @@
|
||||||
import base64
|
import base64
|
||||||
import uuid
|
import uuid
|
||||||
import os
|
import os
|
||||||
from openpyxl.chart import (
|
from openpyxl.chart import LineChart, Reference
|
||||||
PieChart,
|
|
||||||
LineChart,
|
|
||||||
BarChart,
|
|
||||||
Reference,
|
|
||||||
)
|
|
||||||
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
||||||
from openpyxl.drawing.image import Image
|
from openpyxl.drawing.image import Image
|
||||||
from openpyxl import Workbook
|
from openpyxl import Workbook
|
||||||
|
@ -95,9 +90,7 @@ def generate_excel(report,
|
||||||
bottom=Side(border_style='medium', color='00000000'),
|
bottom=Side(border_style='medium', color='00000000'),
|
||||||
top=Side(border_style='medium', color='00000000')
|
top=Side(border_style='medium', color='00000000')
|
||||||
)
|
)
|
||||||
b_border = Border(
|
b_border = Border(bottom=Side(border_style='medium', color='00000000'), )
|
||||||
bottom=Side(border_style='medium', color='00000000'),
|
|
||||||
)
|
|
||||||
|
|
||||||
b_c_alignment = Alignment(vertical='bottom',
|
b_c_alignment = Alignment(vertical='bottom',
|
||||||
horizontal='center',
|
horizontal='center',
|
||||||
|
|
|
@ -1,12 +1,8 @@
|
||||||
import base64
|
import base64
|
||||||
import uuid
|
import uuid
|
||||||
import os
|
import os
|
||||||
from openpyxl.chart import (
|
from decimal import Decimal
|
||||||
PieChart,
|
from openpyxl.chart import PieChart, LineChart, Reference
|
||||||
LineChart,
|
|
||||||
BarChart,
|
|
||||||
Reference,
|
|
||||||
)
|
|
||||||
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
||||||
from openpyxl.drawing.image import Image
|
from openpyxl.drawing.image import Image
|
||||||
from openpyxl import Workbook
|
from openpyxl import Workbook
|
||||||
|
@ -95,9 +91,7 @@ def generate_excel(report,
|
||||||
bottom=Side(border_style='medium', color='00000000'),
|
bottom=Side(border_style='medium', color='00000000'),
|
||||||
top=Side(border_style='medium', color='00000000')
|
top=Side(border_style='medium', color='00000000')
|
||||||
)
|
)
|
||||||
b_border = Border(
|
b_border = Border(bottom=Side(border_style='medium', color='00000000'), )
|
||||||
bottom=Side(border_style='medium', color='00000000'),
|
|
||||||
)
|
|
||||||
|
|
||||||
b_c_alignment = Alignment(vertical='bottom',
|
b_c_alignment = Alignment(vertical='bottom',
|
||||||
horizontal='center',
|
horizontal='center',
|
||||||
|
@ -743,7 +737,7 @@ def generate_excel(report,
|
||||||
|
|
||||||
|
|
||||||
def sum_list(lists):
|
def sum_list(lists):
|
||||||
total = 0
|
total = Decimal(0.0)
|
||||||
|
|
||||||
for i in range(0, len(lists)):
|
for i in range(0, len(lists)):
|
||||||
total += lists[i]
|
total += lists[i]
|
||||||
|
|
|
@ -1,10 +1,7 @@
|
||||||
import base64
|
import base64
|
||||||
import uuid
|
import uuid
|
||||||
import os
|
import os
|
||||||
from openpyxl.chart import (
|
from openpyxl.chart import LineChart, Reference
|
||||||
LineChart,
|
|
||||||
Reference,
|
|
||||||
)
|
|
||||||
from openpyxl.chart.label import DataLabelList
|
from openpyxl.chart.label import DataLabelList
|
||||||
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
||||||
from openpyxl.drawing.image import Image
|
from openpyxl.drawing.image import Image
|
||||||
|
@ -160,152 +157,146 @@ def generate_excel(report,
|
||||||
####################################################################################################################
|
####################################################################################################################
|
||||||
reporting_period_data = report['reporting_period']
|
reporting_period_data = report['reporting_period']
|
||||||
|
|
||||||
has_energy_data_flag = True
|
|
||||||
|
|
||||||
if "names" not in reporting_period_data.keys() or \
|
if "names" not in reporting_period_data.keys() or \
|
||||||
reporting_period_data['names'] is None or \
|
reporting_period_data['names'] is None or \
|
||||||
len(reporting_period_data['names']) == 0:
|
len(reporting_period_data['names']) == 0:
|
||||||
has_energy_data_flag = False
|
|
||||||
|
|
||||||
filename = str(uuid.uuid4()) + '.xlsx'
|
filename = str(uuid.uuid4()) + '.xlsx'
|
||||||
wb.save(filename)
|
wb.save(filename)
|
||||||
|
|
||||||
return filename
|
return filename
|
||||||
|
|
||||||
if has_energy_data_flag:
|
ws['B6'].font = title_font
|
||||||
ws['B6'].font = title_font
|
ws['B6'] = name + ' 统计分析'
|
||||||
ws['B6'] = name + ' 统计分析'
|
|
||||||
|
|
||||||
category = reporting_period_data['names']
|
category = reporting_period_data['names']
|
||||||
|
|
||||||
# table_title
|
# table_title
|
||||||
ws['B7'].fill = table_fill
|
ws['B7'].fill = table_fill
|
||||||
ws['B7'].font = title_font
|
ws['B7'].font = title_font
|
||||||
ws['B7'].alignment = c_c_alignment
|
ws['B7'].alignment = c_c_alignment
|
||||||
ws['B7'] = '报告期'
|
ws['B7'] = '报告期'
|
||||||
ws['B7'].border = f_border
|
ws['B7'].border = f_border
|
||||||
|
|
||||||
ws['C7'].font = title_font
|
ws['C7'].font = title_font
|
||||||
ws['C7'].alignment = c_c_alignment
|
ws['C7'].alignment = c_c_alignment
|
||||||
ws['C7'] = '算术平均数'
|
ws['C7'] = '算术平均数'
|
||||||
ws['C7'].border = f_border
|
ws['C7'].border = f_border
|
||||||
|
|
||||||
ws['D7'].font = title_font
|
ws['D7'].font = title_font
|
||||||
ws['D7'].alignment = c_c_alignment
|
ws['D7'].alignment = c_c_alignment
|
||||||
ws['D7'] = '中位数'
|
ws['D7'] = '中位数'
|
||||||
ws['D7'].border = f_border
|
ws['D7'].border = f_border
|
||||||
|
|
||||||
ws['E7'].font = title_font
|
ws['E7'].font = title_font
|
||||||
ws['E7'].alignment = c_c_alignment
|
ws['E7'].alignment = c_c_alignment
|
||||||
ws['E7'] = '最小值'
|
ws['E7'] = '最小值'
|
||||||
ws['E7'].border = f_border
|
ws['E7'].border = f_border
|
||||||
|
|
||||||
ws['F7'].font = title_font
|
ws['F7'].font = title_font
|
||||||
ws['F7'].alignment = c_c_alignment
|
ws['F7'].alignment = c_c_alignment
|
||||||
ws['F7'] = '最大值'
|
ws['F7'] = '最大值'
|
||||||
ws['F7'].border = f_border
|
ws['F7'].border = f_border
|
||||||
|
|
||||||
ws['G7'].font = title_font
|
ws['G7'].font = title_font
|
||||||
ws['G7'].alignment = c_c_alignment
|
ws['G7'].alignment = c_c_alignment
|
||||||
ws['G7'] = '样本标准差'
|
ws['G7'] = '样本标准差'
|
||||||
ws['G7'].border = f_border
|
ws['G7'].border = f_border
|
||||||
|
|
||||||
ws['H7'].font = title_font
|
ws['H7'].font = title_font
|
||||||
ws['H7'].alignment = c_c_alignment
|
ws['H7'].alignment = c_c_alignment
|
||||||
ws['H7'] = '样本方差'
|
ws['H7'] = '样本方差'
|
||||||
ws['H7'].border = f_border
|
ws['H7'].border = f_border
|
||||||
|
|
||||||
# table_data
|
# table_data
|
||||||
|
|
||||||
for i, value in enumerate(category):
|
for i, value in enumerate(category):
|
||||||
row = i * 2 + 8
|
row = i * 2 + 8
|
||||||
ws['B' + str(row)].font = name_font
|
ws['B' + str(row)].font = name_font
|
||||||
ws['B' + str(row)].alignment = c_c_alignment
|
ws['B' + str(row)].alignment = c_c_alignment
|
||||||
ws['B' + str(row)] = reporting_period_data['names'][i] + " (" + reporting_period_data['units'][i] + " )"
|
ws['B' + str(row)] = reporting_period_data['names'][i] + " (" + reporting_period_data['units'][i] + " )"
|
||||||
ws['B' + str(row)].border = f_border
|
ws['B' + str(row)].border = f_border
|
||||||
|
|
||||||
ws['B' + str(row + 1)].font = name_font
|
ws['B' + str(row + 1)].font = name_font
|
||||||
ws['B' + str(row + 1)].alignment = c_c_alignment
|
ws['B' + str(row + 1)].alignment = c_c_alignment
|
||||||
ws['B' + str(row + 1)] = "环比"
|
ws['B' + str(row + 1)] = "环比"
|
||||||
ws['B' + str(row + 1)].border = f_border
|
ws['B' + str(row + 1)].border = f_border
|
||||||
|
|
||||||
ws['C' + str(row)].font = name_font
|
ws['C' + str(row)].font = name_font
|
||||||
ws['C' + str(row)].alignment = c_c_alignment
|
ws['C' + str(row)].alignment = c_c_alignment
|
||||||
ws['C' + str(row)] = reporting_period_data['means'][i] \
|
ws['C' + str(row)] = reporting_period_data['means'][i] \
|
||||||
if reporting_period_data['means'][i] is not None else ''
|
if reporting_period_data['means'][i] is not None else ''
|
||||||
ws['C' + str(row)].border = f_border
|
ws['C' + str(row)].border = f_border
|
||||||
ws['C' + str(row)].number_format = '0.00'
|
ws['C' + str(row)].number_format = '0.00'
|
||||||
|
|
||||||
ws['C' + str(row + 1)].font = name_font
|
ws['C' + str(row + 1)].font = name_font
|
||||||
ws['C' + str(row + 1)].alignment = c_c_alignment
|
ws['C' + str(row + 1)].alignment = c_c_alignment
|
||||||
ws['C' + str(row + 1)] = str(round(reporting_period_data['means_increment_rate'][i] * 100, 2)) + "%" \
|
ws['C' + str(row + 1)] = str(round(reporting_period_data['means_increment_rate'][i] * 100, 2)) + "%" \
|
||||||
if reporting_period_data['means_increment_rate'][i] is not None else '0.00%'
|
if reporting_period_data['means_increment_rate'][i] is not None else '0.00%'
|
||||||
ws['C' + str(row + 1)].border = f_border
|
ws['C' + str(row + 1)].border = f_border
|
||||||
|
|
||||||
ws['D' + str(row)].font = name_font
|
ws['D' + str(row)].font = name_font
|
||||||
ws['D' + str(row)].alignment = c_c_alignment
|
ws['D' + str(row)].alignment = c_c_alignment
|
||||||
ws['D' + str(row)] = reporting_period_data['medians'][i] \
|
ws['D' + str(row)] = reporting_period_data['medians'][i] \
|
||||||
if reporting_period_data['medians'][i] is not None else ''
|
if reporting_period_data['medians'][i] is not None else ''
|
||||||
ws['D' + str(row)].border = f_border
|
ws['D' + str(row)].border = f_border
|
||||||
ws['D' + str(row)].number_format = '0.00'
|
ws['D' + str(row)].number_format = '0.00'
|
||||||
|
|
||||||
ws['D' + str(row + 1)].font = name_font
|
ws['D' + str(row + 1)].font = name_font
|
||||||
ws['D' + str(row + 1)].alignment = c_c_alignment
|
ws['D' + str(row + 1)].alignment = c_c_alignment
|
||||||
ws['D' + str(row + 1)] = str(round(reporting_period_data['medians_increment_rate'][i] * 100, 2)) + "%" \
|
ws['D' + str(row + 1)] = str(round(reporting_period_data['medians_increment_rate'][i] * 100, 2)) + "%" \
|
||||||
if reporting_period_data['medians_increment_rate'][i] is not None else '0.00%'
|
if reporting_period_data['medians_increment_rate'][i] is not None else '0.00%'
|
||||||
ws['D' + str(row + 1)].border = f_border
|
ws['D' + str(row + 1)].border = f_border
|
||||||
|
|
||||||
ws['E' + str(row)].font = name_font
|
ws['E' + str(row)].font = name_font
|
||||||
ws['E' + str(row)].alignment = c_c_alignment
|
ws['E' + str(row)].alignment = c_c_alignment
|
||||||
ws['E' + str(row)] = reporting_period_data['minimums'][i] \
|
ws['E' + str(row)] = reporting_period_data['minimums'][i] \
|
||||||
if reporting_period_data['minimums'][i] is not None else ''
|
if reporting_period_data['minimums'][i] is not None else ''
|
||||||
ws['E' + str(row)].border = f_border
|
ws['E' + str(row)].border = f_border
|
||||||
ws['E' + str(row)].number_format = '0.00'
|
ws['E' + str(row)].number_format = '0.00'
|
||||||
|
|
||||||
ws['E' + str(row + 1)].font = name_font
|
ws['E' + str(row + 1)].font = name_font
|
||||||
ws['E' + str(row + 1)].alignment = c_c_alignment
|
ws['E' + str(row + 1)].alignment = c_c_alignment
|
||||||
ws['E' + str(row + 1)] = str(round(reporting_period_data['minimums_increment_rate'][i] * 100, 2)) + "%" \
|
ws['E' + str(row + 1)] = str(round(reporting_period_data['minimums_increment_rate'][i] * 100, 2)) + "%" \
|
||||||
if reporting_period_data['minimums_increment_rate'][i] is not None else '0.00%'
|
if reporting_period_data['minimums_increment_rate'][i] is not None else '0.00%'
|
||||||
ws['E' + str(row + 1)].border = f_border
|
ws['E' + str(row + 1)].border = f_border
|
||||||
|
|
||||||
ws['F' + str(row)].font = name_font
|
ws['F' + str(row)].font = name_font
|
||||||
ws['F' + str(row)].alignment = c_c_alignment
|
ws['F' + str(row)].alignment = c_c_alignment
|
||||||
ws['F' + str(row)] = reporting_period_data['maximums'][i] \
|
ws['F' + str(row)] = reporting_period_data['maximums'][i] \
|
||||||
if reporting_period_data['maximums'][i] is not None else ''
|
if reporting_period_data['maximums'][i] is not None else ''
|
||||||
ws['F' + str(row)].border = f_border
|
ws['F' + str(row)].border = f_border
|
||||||
ws['F' + str(row)].number_format = '0.00'
|
ws['F' + str(row)].number_format = '0.00'
|
||||||
|
|
||||||
ws['F' + str(row + 1)].font = name_font
|
ws['F' + str(row + 1)].font = name_font
|
||||||
ws['F' + str(row + 1)].alignment = c_c_alignment
|
ws['F' + str(row + 1)].alignment = c_c_alignment
|
||||||
ws['F' + str(row + 1)] = str(round(reporting_period_data['maximums_increment_rate'][i] * 100, 2)) + "%" \
|
ws['F' + str(row + 1)] = str(round(reporting_period_data['maximums_increment_rate'][i] * 100, 2)) + "%" \
|
||||||
if reporting_period_data['maximums_increment_rate'][i] is not None else '0.00%'
|
if reporting_period_data['maximums_increment_rate'][i] is not None else '0.00%'
|
||||||
ws['F' + str(row + 1)].border = f_border
|
ws['F' + str(row + 1)].border = f_border
|
||||||
|
|
||||||
ws['G' + str(row)].font = name_font
|
ws['G' + str(row)].font = name_font
|
||||||
ws['G' + str(row)].alignment = c_c_alignment
|
ws['G' + str(row)].alignment = c_c_alignment
|
||||||
ws['G' + str(row)] = reporting_period_data['stdevs'][i] \
|
ws['G' + str(row)] = reporting_period_data['stdevs'][i] \
|
||||||
if reporting_period_data['stdevs'][i] is not None else ''
|
if reporting_period_data['stdevs'][i] is not None else ''
|
||||||
ws['G' + str(row)].border = f_border
|
ws['G' + str(row)].border = f_border
|
||||||
ws['G' + str(row)].number_format = '0.00'
|
ws['G' + str(row)].number_format = '0.00'
|
||||||
|
|
||||||
ws['G' + str(row + 1)].font = name_font
|
ws['G' + str(row + 1)].font = name_font
|
||||||
ws['G' + str(row + 1)].alignment = c_c_alignment
|
ws['G' + str(row + 1)].alignment = c_c_alignment
|
||||||
ws['G' + str(row + 1)] = str(round(reporting_period_data['stdevs_increment_rate'][i] * 100, 2)) + "%" \
|
ws['G' + str(row + 1)] = str(round(reporting_period_data['stdevs_increment_rate'][i] * 100, 2)) + "%" \
|
||||||
if reporting_period_data['stdevs_increment_rate'][i] is not None else '0.00%'
|
if reporting_period_data['stdevs_increment_rate'][i] is not None else '0.00%'
|
||||||
ws['G' + str(row + 1)].border = f_border
|
ws['G' + str(row + 1)].border = f_border
|
||||||
|
|
||||||
ws['H' + str(row)].font = name_font
|
ws['H' + str(row)].font = name_font
|
||||||
ws['H' + str(row)].alignment = c_c_alignment
|
ws['H' + str(row)].alignment = c_c_alignment
|
||||||
ws['H' + str(row)] = reporting_period_data['variances'][i] \
|
ws['H' + str(row)] = reporting_period_data['variances'][i] \
|
||||||
if reporting_period_data['variances'][i] is not None else ''
|
if reporting_period_data['variances'][i] is not None else ''
|
||||||
ws['H' + str(row)].border = f_border
|
ws['H' + str(row)].border = f_border
|
||||||
ws['H' + str(row)].number_format = '0.00'
|
ws['H' + str(row)].number_format = '0.00'
|
||||||
|
|
||||||
ws['H' + str(row + 1)].font = name_font
|
ws['H' + str(row + 1)].font = name_font
|
||||||
ws['H' + str(row + 1)].alignment = c_c_alignment
|
ws['H' + str(row + 1)].alignment = c_c_alignment
|
||||||
ws['H' + str(row + 1)] = str(round(reporting_period_data['variances_increment_rate'][i] * 100, 2)) + "%" \
|
ws['H' + str(row + 1)] = str(round(reporting_period_data['variances_increment_rate'][i] * 100, 2)) + "%" \
|
||||||
if reporting_period_data['variances_increment_rate'][i] is not None else '0.00%'
|
if reporting_period_data['variances_increment_rate'][i] is not None else '0.00%'
|
||||||
ws['H' + str(row + 1)].border = f_border
|
ws['H' + str(row + 1)].border = f_border
|
||||||
|
|
||||||
####################################################################################################################
|
####################################################################################################################
|
||||||
# Second: 详细数据
|
# Second: 详细数据
|
||||||
|
|
|
@ -1,14 +1,9 @@
|
||||||
import base64
|
import base64
|
||||||
import uuid
|
import uuid
|
||||||
import os
|
import os
|
||||||
from openpyxl.chart import (
|
from openpyxl.styles import Border, Side, Alignment, Font
|
||||||
BarChart,
|
|
||||||
Reference,
|
|
||||||
)
|
|
||||||
from openpyxl.styles import PatternFill, Border, Side, Alignment, Protection, Font
|
|
||||||
from openpyxl.drawing.image import Image
|
from openpyxl.drawing.image import Image
|
||||||
from openpyxl import Workbook
|
from openpyxl import Workbook
|
||||||
from openpyxl.chart.label import DataLabelList
|
|
||||||
|
|
||||||
|
|
||||||
########################################################################################################################
|
########################################################################################################################
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import base64
|
import base64
|
||||||
import uuid
|
import uuid
|
||||||
import os
|
import os
|
||||||
from openpyxl.styles import PatternFill, Border, Side, Alignment, Protection, Font
|
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
||||||
from openpyxl.drawing.image import Image
|
from openpyxl.drawing.image import Image
|
||||||
from openpyxl import Workbook
|
from openpyxl import Workbook
|
||||||
|
|
||||||
|
@ -103,12 +103,6 @@ def generate_excel(report, space_name, reporting_start_datetime_local, reporting
|
||||||
wrap_text=True,
|
wrap_text=True,
|
||||||
shrink_to_fit=False,
|
shrink_to_fit=False,
|
||||||
indent=0)
|
indent=0)
|
||||||
c_r_alignment = Alignment(vertical='bottom',
|
|
||||||
horizontal='center',
|
|
||||||
text_rotation=0,
|
|
||||||
wrap_text=True,
|
|
||||||
shrink_to_fit=False,
|
|
||||||
indent=0)
|
|
||||||
|
|
||||||
# Img
|
# Img
|
||||||
img = Image("excelexporters/myems.png")
|
img = Image("excelexporters/myems.png")
|
||||||
|
|
|
@ -1,12 +1,7 @@
|
||||||
import base64
|
import base64
|
||||||
import uuid
|
import uuid
|
||||||
import os
|
import os
|
||||||
from openpyxl.chart import (
|
from openpyxl.chart import LineChart, Reference, Series
|
||||||
BarChart,
|
|
||||||
LineChart,
|
|
||||||
Reference,
|
|
||||||
Series
|
|
||||||
)
|
|
||||||
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
||||||
from openpyxl.drawing.image import Image
|
from openpyxl.drawing.image import Image
|
||||||
from openpyxl import Workbook
|
from openpyxl import Workbook
|
||||||
|
|
|
@ -1,12 +1,8 @@
|
||||||
import base64
|
import base64
|
||||||
import uuid
|
import uuid
|
||||||
import os
|
import os
|
||||||
from openpyxl.chart import (
|
from openpyxl.chart import LineChart, Reference
|
||||||
BarChart,
|
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
||||||
LineChart,
|
|
||||||
Reference,
|
|
||||||
)
|
|
||||||
from openpyxl.styles import PatternFill, Border, Side, Alignment, Protection, Font
|
|
||||||
from openpyxl.drawing.image import Image
|
from openpyxl.drawing.image import Image
|
||||||
from openpyxl import Workbook
|
from openpyxl import Workbook
|
||||||
from openpyxl.chart.label import DataLabelList
|
from openpyxl.chart.label import DataLabelList
|
||||||
|
|
|
@ -1,12 +1,8 @@
|
||||||
import base64
|
import base64
|
||||||
import uuid
|
import uuid
|
||||||
import os
|
import os
|
||||||
from openpyxl.chart import (
|
from openpyxl.chart import LineChart, Reference
|
||||||
BarChart,
|
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
||||||
LineChart,
|
|
||||||
Reference,
|
|
||||||
)
|
|
||||||
from openpyxl.styles import PatternFill, Border, Side, Alignment, Protection, Font
|
|
||||||
from openpyxl.drawing.image import Image
|
from openpyxl.drawing.image import Image
|
||||||
from openpyxl import Workbook
|
from openpyxl import Workbook
|
||||||
from openpyxl.chart.label import DataLabelList
|
from openpyxl.chart.label import DataLabelList
|
||||||
|
|
|
@ -1,14 +1,9 @@
|
||||||
import base64
|
import base64
|
||||||
import uuid
|
import uuid
|
||||||
import os
|
import os
|
||||||
from openpyxl.chart import (
|
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
||||||
BarChart,
|
|
||||||
Reference,
|
|
||||||
)
|
|
||||||
from openpyxl.styles import PatternFill, Border, Side, Alignment, Protection, Font
|
|
||||||
from openpyxl.drawing.image import Image
|
from openpyxl.drawing.image import Image
|
||||||
from openpyxl import Workbook
|
from openpyxl import Workbook
|
||||||
from openpyxl.chart.label import DataLabelList
|
|
||||||
|
|
||||||
|
|
||||||
########################################################################################################################
|
########################################################################################################################
|
||||||
|
|
|
@ -1,12 +1,7 @@
|
||||||
import base64
|
import base64
|
||||||
import uuid
|
import uuid
|
||||||
import os
|
import os
|
||||||
from openpyxl.chart import (
|
from openpyxl.chart import LineChart, Reference
|
||||||
PieChart,
|
|
||||||
LineChart,
|
|
||||||
BarChart,
|
|
||||||
Reference,
|
|
||||||
)
|
|
||||||
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
||||||
from openpyxl.drawing.image import Image
|
from openpyxl.drawing.image import Image
|
||||||
from openpyxl import Workbook
|
from openpyxl import Workbook
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 248 KiB After Width: | Height: | Size: 150 KiB |
|
@ -1,12 +1,7 @@
|
||||||
import base64
|
import base64
|
||||||
import uuid
|
import uuid
|
||||||
import os
|
import os
|
||||||
from openpyxl.chart import (
|
from openpyxl.chart import LineChart, Reference, Series
|
||||||
BarChart,
|
|
||||||
LineChart,
|
|
||||||
Reference,
|
|
||||||
Series
|
|
||||||
)
|
|
||||||
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
||||||
from openpyxl.drawing.image import Image
|
from openpyxl.drawing.image import Image
|
||||||
from openpyxl import Workbook
|
from openpyxl import Workbook
|
||||||
|
|
|
@ -1,12 +1,8 @@
|
||||||
import base64
|
import base64
|
||||||
import uuid
|
import uuid
|
||||||
import os
|
import os
|
||||||
from openpyxl.chart import (
|
from openpyxl.chart import LineChart, Reference
|
||||||
BarChart,
|
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
||||||
LineChart,
|
|
||||||
Reference,
|
|
||||||
)
|
|
||||||
from openpyxl.styles import PatternFill, Border, Side, Alignment, Protection, Font
|
|
||||||
from openpyxl.drawing.image import Image
|
from openpyxl.drawing.image import Image
|
||||||
from openpyxl import Workbook
|
from openpyxl import Workbook
|
||||||
from openpyxl.chart.label import DataLabelList
|
from openpyxl.chart.label import DataLabelList
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import base64
|
import base64
|
||||||
import uuid
|
import uuid
|
||||||
import os
|
import os
|
||||||
from openpyxl.styles import PatternFill, Border, Side, Alignment, Protection, Font
|
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
||||||
from openpyxl.drawing.image import Image
|
from openpyxl.drawing.image import Image
|
||||||
from openpyxl import Workbook
|
from openpyxl import Workbook
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,7 @@
|
||||||
import base64
|
import base64
|
||||||
import uuid
|
import uuid
|
||||||
import os
|
import os
|
||||||
from openpyxl.chart import (
|
from openpyxl.chart import PieChart, LineChart, Reference
|
||||||
PieChart,
|
|
||||||
LineChart,
|
|
||||||
Reference,
|
|
||||||
)
|
|
||||||
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
||||||
from openpyxl.drawing.image import Image
|
from openpyxl.drawing.image import Image
|
||||||
from openpyxl import Workbook
|
from openpyxl import Workbook
|
||||||
|
|
|
@ -1,11 +1,7 @@
|
||||||
import base64
|
import base64
|
||||||
import uuid
|
import uuid
|
||||||
import os
|
import os
|
||||||
from openpyxl.chart import (
|
from openpyxl.chart import PieChart, LineChart, Reference
|
||||||
PieChart,
|
|
||||||
LineChart,
|
|
||||||
Reference,
|
|
||||||
)
|
|
||||||
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
||||||
from openpyxl.drawing.image import Image
|
from openpyxl.drawing.image import Image
|
||||||
from openpyxl import Workbook
|
from openpyxl import Workbook
|
||||||
|
|
|
@ -1,11 +1,7 @@
|
||||||
import base64
|
import base64
|
||||||
import uuid
|
import uuid
|
||||||
import os
|
import os
|
||||||
from openpyxl.chart import (
|
from openpyxl.chart import PieChart, LineChart, Reference
|
||||||
PieChart,
|
|
||||||
LineChart,
|
|
||||||
Reference,
|
|
||||||
)
|
|
||||||
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
||||||
from openpyxl.drawing.image import Image
|
from openpyxl.drawing.image import Image
|
||||||
from openpyxl import Workbook
|
from openpyxl import Workbook
|
||||||
|
@ -116,12 +112,6 @@ def generate_excel(report,
|
||||||
wrap_text=True,
|
wrap_text=True,
|
||||||
shrink_to_fit=False,
|
shrink_to_fit=False,
|
||||||
indent=0)
|
indent=0)
|
||||||
c_r_alignment = Alignment(vertical='bottom',
|
|
||||||
horizontal='center',
|
|
||||||
text_rotation=0,
|
|
||||||
wrap_text=True,
|
|
||||||
shrink_to_fit=False,
|
|
||||||
indent=0)
|
|
||||||
# Img
|
# Img
|
||||||
img = Image("excelexporters/myems.png")
|
img = Image("excelexporters/myems.png")
|
||||||
img.width = img.width * 0.85
|
img.width = img.width * 0.85
|
||||||
|
|
|
@ -1,10 +1,7 @@
|
||||||
import base64
|
import base64
|
||||||
import uuid
|
import uuid
|
||||||
import os
|
import os
|
||||||
from openpyxl.chart import (
|
from openpyxl.chart import LineChart, Reference
|
||||||
LineChart,
|
|
||||||
Reference,
|
|
||||||
)
|
|
||||||
from openpyxl.chart.label import DataLabelList
|
from openpyxl.chart.label import DataLabelList
|
||||||
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
||||||
from openpyxl.drawing.image import Image
|
from openpyxl.drawing.image import Image
|
||||||
|
@ -161,98 +158,92 @@ def generate_excel(report,
|
||||||
####################################################################################################################
|
####################################################################################################################
|
||||||
reporting_period_data = report['reporting_period']
|
reporting_period_data = report['reporting_period']
|
||||||
|
|
||||||
has_energy_data_flag = True
|
|
||||||
|
|
||||||
if "names" not in reporting_period_data.keys() or \
|
if "names" not in reporting_period_data.keys() or \
|
||||||
reporting_period_data['names'] is None or \
|
reporting_period_data['names'] is None or \
|
||||||
len(reporting_period_data['names']) == 0:
|
len(reporting_period_data['names']) == 0:
|
||||||
has_energy_data_flag = False
|
|
||||||
|
|
||||||
filename = str(uuid.uuid4()) + '.xlsx'
|
filename = str(uuid.uuid4()) + '.xlsx'
|
||||||
wb.save(filename)
|
wb.save(filename)
|
||||||
|
|
||||||
return filename
|
return filename
|
||||||
|
|
||||||
if has_energy_data_flag:
|
ws['B6'].font = title_font
|
||||||
ws['B6'].font = title_font
|
ws['B6'] = name + ' 统计分析'
|
||||||
ws['B6'] = name + ' 统计分析'
|
|
||||||
|
|
||||||
category = reporting_period_data['names']
|
category = reporting_period_data['names']
|
||||||
|
|
||||||
# table_title
|
# table_title
|
||||||
ws['B7'].fill = table_fill
|
ws['B7'].fill = table_fill
|
||||||
ws['B7'].font = title_font
|
ws['B7'].font = title_font
|
||||||
ws['B7'].alignment = c_c_alignment
|
ws['B7'].alignment = c_c_alignment
|
||||||
ws['B7'] = '报告期'
|
ws['B7'] = '报告期'
|
||||||
ws['B7'].border = f_border
|
ws['B7'].border = f_border
|
||||||
|
|
||||||
ws['C7'].font = title_font
|
ws['C7'].font = title_font
|
||||||
ws['C7'].alignment = c_c_alignment
|
ws['C7'].alignment = c_c_alignment
|
||||||
ws['C7'] = '平均负荷'
|
ws['C7'] = '平均负荷'
|
||||||
ws['C7'].border = f_border
|
ws['C7'].border = f_border
|
||||||
|
|
||||||
ws['D7'].font = title_font
|
ws['D7'].font = title_font
|
||||||
ws['D7'].alignment = c_c_alignment
|
ws['D7'].alignment = c_c_alignment
|
||||||
ws['D7'] = '最大负荷'
|
ws['D7'] = '最大负荷'
|
||||||
ws['D7'].border = f_border
|
ws['D7'].border = f_border
|
||||||
|
|
||||||
ws['E7'].font = title_font
|
ws['E7'].font = title_font
|
||||||
ws['E7'].alignment = c_c_alignment
|
ws['E7'].alignment = c_c_alignment
|
||||||
ws['E7'] = '负荷系数'
|
ws['E7'] = '负荷系数'
|
||||||
ws['E7'].border = f_border
|
ws['E7'].border = f_border
|
||||||
|
|
||||||
# table_data
|
# table_data
|
||||||
|
|
||||||
for i, value in enumerate(category):
|
for i, value in enumerate(category):
|
||||||
row = i * 2 + 8
|
row = i * 2 + 8
|
||||||
ws['B' + str(row)].font = name_font
|
ws['B' + str(row)].font = name_font
|
||||||
ws['B' + str(row)].alignment = c_c_alignment
|
ws['B' + str(row)].alignment = c_c_alignment
|
||||||
ws['B' + str(row)] = reporting_period_data['names'][i] + " (" + reporting_period_data['units'][i] + "/H )"
|
ws['B' + str(row)] = reporting_period_data['names'][i] + " (" + reporting_period_data['units'][i] + "/H )"
|
||||||
ws['B' + str(row)].border = f_border
|
ws['B' + str(row)].border = f_border
|
||||||
|
|
||||||
ws['B' + str(row + 1)].font = name_font
|
ws['B' + str(row + 1)].font = name_font
|
||||||
ws['B' + str(row + 1)].alignment = c_c_alignment
|
ws['B' + str(row + 1)].alignment = c_c_alignment
|
||||||
ws['B' + str(row + 1)] = "环比"
|
ws['B' + str(row + 1)] = "环比"
|
||||||
ws['B' + str(row + 1)].border = f_border
|
ws['B' + str(row + 1)].border = f_border
|
||||||
|
|
||||||
ws['C' + str(row)].font = name_font
|
ws['C' + str(row)].font = name_font
|
||||||
ws['C' + str(row)].alignment = c_c_alignment
|
ws['C' + str(row)].alignment = c_c_alignment
|
||||||
ws['C' + str(row)] = round(reporting_period_data['averages'][i], 2) \
|
ws['C' + str(row)] = round(reporting_period_data['averages'][i], 2) \
|
||||||
if reporting_period_data['averages'][i] is not None else ''
|
if reporting_period_data['averages'][i] is not None else ''
|
||||||
ws['C' + str(row)].border = f_border
|
ws['C' + str(row)].border = f_border
|
||||||
ws['C' + str(row)].number_format = '0.00'
|
ws['C' + str(row)].number_format = '0.00'
|
||||||
|
|
||||||
ws['C' + str(row + 1)].font = name_font
|
ws['C' + str(row + 1)].font = name_font
|
||||||
ws['C' + str(row + 1)].alignment = c_c_alignment
|
ws['C' + str(row + 1)].alignment = c_c_alignment
|
||||||
ws['C' + str(row + 1)] = str(round(reporting_period_data['averages_increment_rate'][i] * 100, 2)) + "%" \
|
ws['C' + str(row + 1)] = str(round(reporting_period_data['averages_increment_rate'][i] * 100, 2)) + "%" \
|
||||||
if reporting_period_data['averages_increment_rate'][i] is not None else '0.00%'
|
if reporting_period_data['averages_increment_rate'][i] is not None else '0.00%'
|
||||||
ws['C' + str(row + 1)].border = f_border
|
ws['C' + str(row + 1)].border = f_border
|
||||||
|
|
||||||
ws['D' + str(row)].font = name_font
|
ws['D' + str(row)].font = name_font
|
||||||
ws['D' + str(row)].alignment = c_c_alignment
|
ws['D' + str(row)].alignment = c_c_alignment
|
||||||
ws['D' + str(row)] = round(reporting_period_data['maximums'][i], 2) \
|
ws['D' + str(row)] = round(reporting_period_data['maximums'][i], 2) \
|
||||||
if reporting_period_data['maximums'][i] is not None else ''
|
if reporting_period_data['maximums'][i] is not None else ''
|
||||||
ws['D' + str(row)].border = f_border
|
ws['D' + str(row)].border = f_border
|
||||||
ws['D' + str(row)].number_format = '0.00'
|
ws['D' + str(row)].number_format = '0.00'
|
||||||
|
|
||||||
ws['D' + str(row + 1)].font = name_font
|
ws['D' + str(row + 1)].font = name_font
|
||||||
ws['D' + str(row + 1)].alignment = c_c_alignment
|
ws['D' + str(row + 1)].alignment = c_c_alignment
|
||||||
ws['D' + str(row + 1)] = str(round(reporting_period_data['maximums_increment_rate'][i] * 100, 2)) + "%" \
|
ws['D' + str(row + 1)] = str(round(reporting_period_data['maximums_increment_rate'][i] * 100, 2)) + "%" \
|
||||||
if reporting_period_data['maximums_increment_rate'][i] is not None else '0.00%'
|
if reporting_period_data['maximums_increment_rate'][i] is not None else '0.00%'
|
||||||
ws['D' + str(row + 1)].border = f_border
|
ws['D' + str(row + 1)].border = f_border
|
||||||
|
|
||||||
ws['E' + str(row)].font = name_font
|
ws['E' + str(row)].font = name_font
|
||||||
ws['E' + str(row)].alignment = c_c_alignment
|
ws['E' + str(row)].alignment = c_c_alignment
|
||||||
ws['E' + str(row)] = round(reporting_period_data['factors'][i], 2) \
|
ws['E' + str(row)] = round(reporting_period_data['factors'][i], 2) \
|
||||||
if reporting_period_data['factors'][i] is not None else ''
|
if reporting_period_data['factors'][i] is not None else ''
|
||||||
ws['E' + str(row)].border = f_border
|
ws['E' + str(row)].border = f_border
|
||||||
ws['E' + str(row)].number_format = '0.00'
|
ws['E' + str(row)].number_format = '0.00'
|
||||||
|
|
||||||
ws['E' + str(row + 1)].font = name_font
|
ws['E' + str(row + 1)].font = name_font
|
||||||
ws['E' + str(row + 1)].alignment = c_c_alignment
|
ws['E' + str(row + 1)].alignment = c_c_alignment
|
||||||
ws['E' + str(row + 1)] = str(round(reporting_period_data['factors_increment_rate'][i] * 100, 2)) + "%" \
|
ws['E' + str(row + 1)] = str(round(reporting_period_data['factors_increment_rate'][i] * 100, 2)) + "%" \
|
||||||
if reporting_period_data['factors_increment_rate'][i] is not None else '0.00%'
|
if reporting_period_data['factors_increment_rate'][i] is not None else '0.00%'
|
||||||
ws['E' + str(row + 1)].border = f_border
|
ws['E' + str(row + 1)].border = f_border
|
||||||
|
|
||||||
####################################################################################################################
|
####################################################################################################################
|
||||||
# Second: 报告期单位面积消耗
|
# Second: 报告期单位面积消耗
|
||||||
|
@ -261,58 +252,57 @@ def generate_excel(report,
|
||||||
# per_unit_area_start_row_number + 2 ~ per_unit_area_start_row_number + 2 + ca_len : table_data
|
# per_unit_area_start_row_number + 2 ~ per_unit_area_start_row_number + 2 + ca_len : table_data
|
||||||
####################################################################################################################
|
####################################################################################################################
|
||||||
|
|
||||||
if has_energy_data_flag:
|
names = reporting_period_data['names']
|
||||||
names = reporting_period_data['names']
|
ca_len = len(names)
|
||||||
ca_len = len(names)
|
per_unit_area_start_row_number = 9 + ca_len * 2
|
||||||
per_unit_area_start_row_number = 9 + ca_len * 2
|
|
||||||
|
|
||||||
ws['B' + str(per_unit_area_start_row_number)].font = title_font
|
ws['B' + str(per_unit_area_start_row_number)].font = title_font
|
||||||
ws['B' + str(per_unit_area_start_row_number)] = name + ' 单位面积值' + str(report['shopfloor']['area']) + 'M²'
|
ws['B' + str(per_unit_area_start_row_number)] = name + ' 单位面积值' + str(report['shopfloor']['area']) + 'M²'
|
||||||
|
|
||||||
category = reporting_period_data['names']
|
category = reporting_period_data['names']
|
||||||
|
|
||||||
# table_title
|
# table_title
|
||||||
ws['B' + str(per_unit_area_start_row_number + 1)].fill = table_fill
|
ws['B' + str(per_unit_area_start_row_number + 1)].fill = table_fill
|
||||||
ws['B' + str(per_unit_area_start_row_number + 1)].font = title_font
|
ws['B' + str(per_unit_area_start_row_number + 1)].font = title_font
|
||||||
ws['B' + str(per_unit_area_start_row_number + 1)].alignment = c_c_alignment
|
ws['B' + str(per_unit_area_start_row_number + 1)].alignment = c_c_alignment
|
||||||
ws['B' + str(per_unit_area_start_row_number + 1)] = '报告期'
|
ws['B' + str(per_unit_area_start_row_number + 1)] = '报告期'
|
||||||
ws['B' + str(per_unit_area_start_row_number + 1)].border = f_border
|
ws['B' + str(per_unit_area_start_row_number + 1)].border = f_border
|
||||||
|
|
||||||
ws['C' + str(per_unit_area_start_row_number + 1)].font = title_font
|
ws['C' + str(per_unit_area_start_row_number + 1)].font = title_font
|
||||||
ws['C' + str(per_unit_area_start_row_number + 1)].alignment = c_c_alignment
|
ws['C' + str(per_unit_area_start_row_number + 1)].alignment = c_c_alignment
|
||||||
ws['C' + str(per_unit_area_start_row_number + 1)] = '平均负荷'
|
ws['C' + str(per_unit_area_start_row_number + 1)] = '平均负荷'
|
||||||
ws['C' + str(per_unit_area_start_row_number + 1)].border = f_border
|
ws['C' + str(per_unit_area_start_row_number + 1)].border = f_border
|
||||||
|
|
||||||
ws['D' + str(per_unit_area_start_row_number + 1)].font = title_font
|
ws['D' + str(per_unit_area_start_row_number + 1)].font = title_font
|
||||||
ws['D' + str(per_unit_area_start_row_number + 1)].alignment = c_c_alignment
|
ws['D' + str(per_unit_area_start_row_number + 1)].alignment = c_c_alignment
|
||||||
ws['D' + str(per_unit_area_start_row_number + 1)] = '最大负荷'
|
ws['D' + str(per_unit_area_start_row_number + 1)] = '最大负荷'
|
||||||
ws['D' + str(per_unit_area_start_row_number + 1)].border = f_border
|
ws['D' + str(per_unit_area_start_row_number + 1)].border = f_border
|
||||||
|
|
||||||
# table_data
|
# table_data
|
||||||
|
|
||||||
for i, value in enumerate(category):
|
for i, value in enumerate(category):
|
||||||
row_data = per_unit_area_start_row_number + 2 + i
|
row_data = per_unit_area_start_row_number + 2 + i
|
||||||
ws['B' + str(row_data)].font = name_font
|
ws['B' + str(row_data)].font = name_font
|
||||||
ws['B' + str(row_data)].alignment = c_c_alignment
|
ws['B' + str(row_data)].alignment = c_c_alignment
|
||||||
ws['B' + str(row_data)] = reporting_period_data['names'][i] + " (" + reporting_period_data['units'][
|
ws['B' + str(row_data)] = reporting_period_data['names'][i] + " (" + reporting_period_data['units'][
|
||||||
i] + "/H/M²)"
|
i] + "/H/M²)"
|
||||||
ws['B' + str(row_data)].border = f_border
|
ws['B' + str(row_data)].border = f_border
|
||||||
|
|
||||||
ws['C' + str(row_data)].font = name_font
|
ws['C' + str(row_data)].font = name_font
|
||||||
ws['C' + str(row_data)].alignment = c_c_alignment
|
ws['C' + str(row_data)].alignment = c_c_alignment
|
||||||
if reporting_period_data['averages_per_unit_area'][i] \
|
if reporting_period_data['averages_per_unit_area'][i] \
|
||||||
or reporting_period_data['averages_per_unit_area'][i] == 0:
|
or reporting_period_data['averages_per_unit_area'][i] == 0:
|
||||||
ws['C' + str(row_data)] = round(reporting_period_data['averages_per_unit_area'][i], 2)
|
ws['C' + str(row_data)] = round(reporting_period_data['averages_per_unit_area'][i], 2)
|
||||||
ws['C' + str(row_data)].border = f_border
|
ws['C' + str(row_data)].border = f_border
|
||||||
ws['C' + str(row_data)].number_format = '0.00'
|
ws['C' + str(row_data)].number_format = '0.00'
|
||||||
|
|
||||||
ws['D' + str(row_data)].font = name_font
|
ws['D' + str(row_data)].font = name_font
|
||||||
ws['D' + str(row_data)].alignment = c_c_alignment
|
ws['D' + str(row_data)].alignment = c_c_alignment
|
||||||
if reporting_period_data['maximums_per_unit_area'][i] \
|
if reporting_period_data['maximums_per_unit_area'][i] \
|
||||||
or reporting_period_data['maximums_per_unit_area'][i] == 0:
|
or reporting_period_data['maximums_per_unit_area'][i] == 0:
|
||||||
ws['D' + str(row_data)] = round(reporting_period_data['maximums_per_unit_area'][i], 2)
|
ws['D' + str(row_data)] = round(reporting_period_data['maximums_per_unit_area'][i], 2)
|
||||||
ws['D' + str(row_data)].border = f_border
|
ws['D' + str(row_data)].border = f_border
|
||||||
ws['D' + str(row_data)].number_format = '0.00'
|
ws['D' + str(row_data)].number_format = '0.00'
|
||||||
|
|
||||||
####################################################################################################################
|
####################################################################################################################
|
||||||
# Third: 详细数据
|
# Third: 详细数据
|
||||||
|
|
|
@ -1,11 +1,8 @@
|
||||||
import base64
|
import base64
|
||||||
import uuid
|
import uuid
|
||||||
import os
|
import os
|
||||||
from openpyxl.chart import (
|
from decimal import Decimal
|
||||||
PieChart,
|
from openpyxl.chart import PieChart, LineChart, Reference
|
||||||
LineChart,
|
|
||||||
Reference,
|
|
||||||
)
|
|
||||||
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
||||||
from openpyxl.drawing.image import Image
|
from openpyxl.drawing.image import Image
|
||||||
from openpyxl import Workbook
|
from openpyxl import Workbook
|
||||||
|
@ -782,7 +779,7 @@ def generate_excel(report,
|
||||||
|
|
||||||
|
|
||||||
def sum_list(lists):
|
def sum_list(lists):
|
||||||
total = 0
|
total = Decimal(0)
|
||||||
|
|
||||||
for i in range(0, len(lists)):
|
for i in range(0, len(lists)):
|
||||||
total += lists[i]
|
total += lists[i]
|
||||||
|
|
|
@ -1,10 +1,7 @@
|
||||||
import base64
|
import base64
|
||||||
import uuid
|
import uuid
|
||||||
import os
|
import os
|
||||||
from openpyxl.chart import (
|
from openpyxl.chart import LineChart, Reference
|
||||||
LineChart,
|
|
||||||
Reference,
|
|
||||||
)
|
|
||||||
from openpyxl.chart.label import DataLabelList
|
from openpyxl.chart.label import DataLabelList
|
||||||
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
||||||
from openpyxl.drawing.image import Image
|
from openpyxl.drawing.image import Image
|
||||||
|
@ -160,152 +157,146 @@ def generate_excel(report,
|
||||||
####################################################################################################################
|
####################################################################################################################
|
||||||
reporting_period_data = report['reporting_period']
|
reporting_period_data = report['reporting_period']
|
||||||
|
|
||||||
has_energy_data_flag = True
|
|
||||||
|
|
||||||
if "names" not in reporting_period_data.keys() or \
|
if "names" not in reporting_period_data.keys() or \
|
||||||
reporting_period_data['names'] is None or \
|
reporting_period_data['names'] is None or \
|
||||||
len(reporting_period_data['names']) == 0:
|
len(reporting_period_data['names']) == 0:
|
||||||
has_energy_data_flag = False
|
|
||||||
|
|
||||||
filename = str(uuid.uuid4()) + '.xlsx'
|
filename = str(uuid.uuid4()) + '.xlsx'
|
||||||
wb.save(filename)
|
wb.save(filename)
|
||||||
|
|
||||||
return filename
|
return filename
|
||||||
|
|
||||||
if has_energy_data_flag:
|
ws['B6'].font = title_font
|
||||||
ws['B6'].font = title_font
|
ws['B6'] = name + ' 统计分析'
|
||||||
ws['B6'] = name + ' 统计分析'
|
|
||||||
|
|
||||||
category = reporting_period_data['names']
|
category = reporting_period_data['names']
|
||||||
|
|
||||||
# table_title
|
# table_title
|
||||||
ws['B7'].fill = table_fill
|
ws['B7'].fill = table_fill
|
||||||
ws['B7'].font = title_font
|
ws['B7'].font = title_font
|
||||||
ws['B7'].alignment = c_c_alignment
|
ws['B7'].alignment = c_c_alignment
|
||||||
ws['B7'] = '报告期'
|
ws['B7'] = '报告期'
|
||||||
ws['B7'].border = f_border
|
ws['B7'].border = f_border
|
||||||
|
|
||||||
ws['C7'].font = title_font
|
ws['C7'].font = title_font
|
||||||
ws['C7'].alignment = c_c_alignment
|
ws['C7'].alignment = c_c_alignment
|
||||||
ws['C7'] = '算术平均数'
|
ws['C7'] = '算术平均数'
|
||||||
ws['C7'].border = f_border
|
ws['C7'].border = f_border
|
||||||
|
|
||||||
ws['D7'].font = title_font
|
ws['D7'].font = title_font
|
||||||
ws['D7'].alignment = c_c_alignment
|
ws['D7'].alignment = c_c_alignment
|
||||||
ws['D7'] = '中位数'
|
ws['D7'] = '中位数'
|
||||||
ws['D7'].border = f_border
|
ws['D7'].border = f_border
|
||||||
|
|
||||||
ws['E7'].font = title_font
|
ws['E7'].font = title_font
|
||||||
ws['E7'].alignment = c_c_alignment
|
ws['E7'].alignment = c_c_alignment
|
||||||
ws['E7'] = '最小值'
|
ws['E7'] = '最小值'
|
||||||
ws['E7'].border = f_border
|
ws['E7'].border = f_border
|
||||||
|
|
||||||
ws['F7'].font = title_font
|
ws['F7'].font = title_font
|
||||||
ws['F7'].alignment = c_c_alignment
|
ws['F7'].alignment = c_c_alignment
|
||||||
ws['F7'] = '最大值'
|
ws['F7'] = '最大值'
|
||||||
ws['F7'].border = f_border
|
ws['F7'].border = f_border
|
||||||
|
|
||||||
ws['G7'].font = title_font
|
ws['G7'].font = title_font
|
||||||
ws['G7'].alignment = c_c_alignment
|
ws['G7'].alignment = c_c_alignment
|
||||||
ws['G7'] = '样本标准差'
|
ws['G7'] = '样本标准差'
|
||||||
ws['G7'].border = f_border
|
ws['G7'].border = f_border
|
||||||
|
|
||||||
ws['H7'].font = title_font
|
ws['H7'].font = title_font
|
||||||
ws['H7'].alignment = c_c_alignment
|
ws['H7'].alignment = c_c_alignment
|
||||||
ws['H7'] = '样本方差'
|
ws['H7'] = '样本方差'
|
||||||
ws['H7'].border = f_border
|
ws['H7'].border = f_border
|
||||||
|
|
||||||
# table_data
|
# table_data
|
||||||
|
|
||||||
for i, value in enumerate(category):
|
for i, value in enumerate(category):
|
||||||
row = i*2 + 8
|
row = i*2 + 8
|
||||||
ws['B' + str(row)].font = name_font
|
ws['B' + str(row)].font = name_font
|
||||||
ws['B' + str(row)].alignment = c_c_alignment
|
ws['B' + str(row)].alignment = c_c_alignment
|
||||||
ws['B' + str(row)] = reporting_period_data['names'][i] + " (" + reporting_period_data['units'][i] + " )"
|
ws['B' + str(row)] = reporting_period_data['names'][i] + " (" + reporting_period_data['units'][i] + " )"
|
||||||
ws['B' + str(row)].border = f_border
|
ws['B' + str(row)].border = f_border
|
||||||
|
|
||||||
ws['B' + str(row + 1)].font = name_font
|
ws['B' + str(row + 1)].font = name_font
|
||||||
ws['B' + str(row + 1)].alignment = c_c_alignment
|
ws['B' + str(row + 1)].alignment = c_c_alignment
|
||||||
ws['B' + str(row + 1)] = "环比"
|
ws['B' + str(row + 1)] = "环比"
|
||||||
ws['B' + str(row + 1)].border = f_border
|
ws['B' + str(row + 1)].border = f_border
|
||||||
|
|
||||||
ws['C' + str(row)].font = name_font
|
ws['C' + str(row)].font = name_font
|
||||||
ws['C' + str(row)].alignment = c_c_alignment
|
ws['C' + str(row)].alignment = c_c_alignment
|
||||||
ws['C' + str(row)] = round(reporting_period_data['means'][i], 2) \
|
ws['C' + str(row)] = round(reporting_period_data['means'][i], 2) \
|
||||||
if reporting_period_data['means'][i] is not None else ''
|
if reporting_period_data['means'][i] is not None else ''
|
||||||
ws['C' + str(row)].border = f_border
|
ws['C' + str(row)].border = f_border
|
||||||
ws['C' + str(row)].number_format = '0.00'
|
ws['C' + str(row)].number_format = '0.00'
|
||||||
|
|
||||||
ws['C' + str(row + 1)].font = name_font
|
ws['C' + str(row + 1)].font = name_font
|
||||||
ws['C' + str(row + 1)].alignment = c_c_alignment
|
ws['C' + str(row + 1)].alignment = c_c_alignment
|
||||||
ws['C' + str(row + 1)] = str(round(reporting_period_data['means_increment_rate'][i] * 100, 2)) + "%" \
|
ws['C' + str(row + 1)] = str(round(reporting_period_data['means_increment_rate'][i] * 100, 2)) + "%" \
|
||||||
if reporting_period_data['means_increment_rate'][i] is not None else '0.00%'
|
if reporting_period_data['means_increment_rate'][i] is not None else '0.00%'
|
||||||
ws['C' + str(row + 1)].border = f_border
|
ws['C' + str(row + 1)].border = f_border
|
||||||
|
|
||||||
ws['D' + str(row)].font = name_font
|
ws['D' + str(row)].font = name_font
|
||||||
ws['D' + str(row)].alignment = c_c_alignment
|
ws['D' + str(row)].alignment = c_c_alignment
|
||||||
ws['D' + str(row)] = round(reporting_period_data['medians'][i], 2) \
|
ws['D' + str(row)] = round(reporting_period_data['medians'][i], 2) \
|
||||||
if reporting_period_data['medians'][i] is not None else ''
|
if reporting_period_data['medians'][i] is not None else ''
|
||||||
ws['D' + str(row)].border = f_border
|
ws['D' + str(row)].border = f_border
|
||||||
ws['D' + str(row)].number_format = '0.00'
|
ws['D' + str(row)].number_format = '0.00'
|
||||||
|
|
||||||
ws['D' + str(row + 1)].font = name_font
|
ws['D' + str(row + 1)].font = name_font
|
||||||
ws['D' + str(row + 1)].alignment = c_c_alignment
|
ws['D' + str(row + 1)].alignment = c_c_alignment
|
||||||
ws['D' + str(row + 1)] = str(round(reporting_period_data['medians_increment_rate'][i] * 100, 2)) + "%" \
|
ws['D' + str(row + 1)] = str(round(reporting_period_data['medians_increment_rate'][i] * 100, 2)) + "%" \
|
||||||
if reporting_period_data['medians_increment_rate'][i] is not None else '0.00%'
|
if reporting_period_data['medians_increment_rate'][i] is not None else '0.00%'
|
||||||
ws['D' + str(row + 1)].border = f_border
|
ws['D' + str(row + 1)].border = f_border
|
||||||
|
|
||||||
ws['E' + str(row)].font = name_font
|
ws['E' + str(row)].font = name_font
|
||||||
ws['E' + str(row)].alignment = c_c_alignment
|
ws['E' + str(row)].alignment = c_c_alignment
|
||||||
ws['E' + str(row)] = round(reporting_period_data['minimums'][i], 2) \
|
ws['E' + str(row)] = round(reporting_period_data['minimums'][i], 2) \
|
||||||
if reporting_period_data['minimums'][i] is not None else ''
|
if reporting_period_data['minimums'][i] is not None else ''
|
||||||
ws['E' + str(row)].border = f_border
|
ws['E' + str(row)].border = f_border
|
||||||
ws['E' + str(row)].number_format = '0.00'
|
ws['E' + str(row)].number_format = '0.00'
|
||||||
|
|
||||||
ws['E' + str(row + 1)].font = name_font
|
ws['E' + str(row + 1)].font = name_font
|
||||||
ws['E' + str(row + 1)].alignment = c_c_alignment
|
ws['E' + str(row + 1)].alignment = c_c_alignment
|
||||||
ws['E' + str(row + 1)] = str(round(reporting_period_data['minimums_increment_rate'][i] * 100, 2)) + "%" \
|
ws['E' + str(row + 1)] = str(round(reporting_period_data['minimums_increment_rate'][i] * 100, 2)) + "%" \
|
||||||
if reporting_period_data['minimums_increment_rate'][i] is not None else '0.00%'
|
if reporting_period_data['minimums_increment_rate'][i] is not None else '0.00%'
|
||||||
ws['E' + str(row + 1)].border = f_border
|
ws['E' + str(row + 1)].border = f_border
|
||||||
|
|
||||||
ws['F' + str(row)].font = name_font
|
ws['F' + str(row)].font = name_font
|
||||||
ws['F' + str(row)].alignment = c_c_alignment
|
ws['F' + str(row)].alignment = c_c_alignment
|
||||||
ws['F' + str(row)] = round(reporting_period_data['maximums'][i], 2) \
|
ws['F' + str(row)] = round(reporting_period_data['maximums'][i], 2) \
|
||||||
if reporting_period_data['maximums'][i] is not None else ''
|
if reporting_period_data['maximums'][i] is not None else ''
|
||||||
ws['F' + str(row)].border = f_border
|
ws['F' + str(row)].border = f_border
|
||||||
ws['F' + str(row)].number_format = '0.00'
|
ws['F' + str(row)].number_format = '0.00'
|
||||||
|
|
||||||
ws['F' + str(row + 1)].font = name_font
|
ws['F' + str(row + 1)].font = name_font
|
||||||
ws['F' + str(row + 1)].alignment = c_c_alignment
|
ws['F' + str(row + 1)].alignment = c_c_alignment
|
||||||
ws['F' + str(row + 1)] = str(round(reporting_period_data['maximums_increment_rate'][i] * 100, 2)) + "%" \
|
ws['F' + str(row + 1)] = str(round(reporting_period_data['maximums_increment_rate'][i] * 100, 2)) + "%" \
|
||||||
if reporting_period_data['maximums_increment_rate'][i] is not None else '0.00%'
|
if reporting_period_data['maximums_increment_rate'][i] is not None else '0.00%'
|
||||||
ws['F' + str(row + 1)].border = f_border
|
ws['F' + str(row + 1)].border = f_border
|
||||||
|
|
||||||
ws['G' + str(row)].font = name_font
|
ws['G' + str(row)].font = name_font
|
||||||
ws['G' + str(row)].alignment = c_c_alignment
|
ws['G' + str(row)].alignment = c_c_alignment
|
||||||
ws['G' + str(row)] = round(reporting_period_data['stdevs'][i], 2) \
|
ws['G' + str(row)] = round(reporting_period_data['stdevs'][i], 2) \
|
||||||
if reporting_period_data['stdevs'][i] is not None else ''
|
if reporting_period_data['stdevs'][i] is not None else ''
|
||||||
ws['G' + str(row)].border = f_border
|
ws['G' + str(row)].border = f_border
|
||||||
ws['G' + str(row)].number_format = '0.00'
|
ws['G' + str(row)].number_format = '0.00'
|
||||||
|
|
||||||
ws['G' + str(row + 1)].font = name_font
|
ws['G' + str(row + 1)].font = name_font
|
||||||
ws['G' + str(row + 1)].alignment = c_c_alignment
|
ws['G' + str(row + 1)].alignment = c_c_alignment
|
||||||
ws['G' + str(row + 1)] = str(round(reporting_period_data['stdevs_increment_rate'][i] * 100, 2)) + "%" \
|
ws['G' + str(row + 1)] = str(round(reporting_period_data['stdevs_increment_rate'][i] * 100, 2)) + "%" \
|
||||||
if reporting_period_data['stdevs_increment_rate'][i] is not None else '0.00%'
|
if reporting_period_data['stdevs_increment_rate'][i] is not None else '0.00%'
|
||||||
ws['G' + str(row + 1)].border = f_border
|
ws['G' + str(row + 1)].border = f_border
|
||||||
|
|
||||||
ws['H' + str(row)].font = name_font
|
ws['H' + str(row)].font = name_font
|
||||||
ws['H' + str(row)].alignment = c_c_alignment
|
ws['H' + str(row)].alignment = c_c_alignment
|
||||||
ws['H' + str(row)] = round(reporting_period_data['variances'][i], 2) \
|
ws['H' + str(row)] = round(reporting_period_data['variances'][i], 2) \
|
||||||
if reporting_period_data['variances'][i] is not None else ''
|
if reporting_period_data['variances'][i] is not None else ''
|
||||||
ws['H' + str(row)].border = f_border
|
ws['H' + str(row)].border = f_border
|
||||||
ws['H' + str(row)].number_format = '0.00'
|
ws['H' + str(row)].number_format = '0.00'
|
||||||
|
|
||||||
ws['H' + str(row + 1)].font = name_font
|
ws['H' + str(row + 1)].font = name_font
|
||||||
ws['H' + str(row + 1)].alignment = c_c_alignment
|
ws['H' + str(row + 1)].alignment = c_c_alignment
|
||||||
ws['H' + str(row + 1)] = str(round(reporting_period_data['variances_increment_rate'][i] * 100, 2)) + "%" \
|
ws['H' + str(row + 1)] = str(round(reporting_period_data['variances_increment_rate'][i] * 100, 2)) + "%" \
|
||||||
if reporting_period_data['variances_increment_rate'][i] is not None else '0.00%'
|
if reporting_period_data['variances_increment_rate'][i] is not None else '0.00%'
|
||||||
ws['H' + str(row + 1)].border = f_border
|
ws['H' + str(row + 1)].border = f_border
|
||||||
####################################################################################################################
|
####################################################################################################################
|
||||||
# Second: 报告期消耗
|
# Second: 报告期消耗
|
||||||
# 9 + ca_len * 2: title
|
# 9 + ca_len * 2: title
|
||||||
|
@ -313,111 +304,110 @@ def generate_excel(report,
|
||||||
# per_unit_area_start_row_number + 2 ~ per_unit_area_start_row_number + 2 + ca_len : table_data
|
# per_unit_area_start_row_number + 2 ~ per_unit_area_start_row_number + 2 + ca_len : table_data
|
||||||
####################################################################################################################
|
####################################################################################################################
|
||||||
|
|
||||||
if has_energy_data_flag:
|
names = reporting_period_data['names']
|
||||||
names = reporting_period_data['names']
|
ca_len = len(names)
|
||||||
ca_len = len(names)
|
|
||||||
|
|
||||||
per_unit_area_start_row_number = 9 + ca_len * 2
|
per_unit_area_start_row_number = 9 + ca_len * 2
|
||||||
|
|
||||||
ws['B' + str(per_unit_area_start_row_number)].font = title_font
|
ws['B' + str(per_unit_area_start_row_number)].font = title_font
|
||||||
ws['B' + str(per_unit_area_start_row_number)] = name + ' 单位面积值' + str(report['shopfloor']['area']) + 'M²'
|
ws['B' + str(per_unit_area_start_row_number)] = name + ' 单位面积值' + str(report['shopfloor']['area']) + 'M²'
|
||||||
|
|
||||||
category = reporting_period_data['names']
|
category = reporting_period_data['names']
|
||||||
|
|
||||||
# table_title
|
# table_title
|
||||||
ws['B' + str(per_unit_area_start_row_number + 1)].fill = table_fill
|
ws['B' + str(per_unit_area_start_row_number + 1)].fill = table_fill
|
||||||
ws['B' + str(per_unit_area_start_row_number + 1)].font = title_font
|
ws['B' + str(per_unit_area_start_row_number + 1)].font = title_font
|
||||||
ws['B' + str(per_unit_area_start_row_number + 1)].alignment = c_c_alignment
|
ws['B' + str(per_unit_area_start_row_number + 1)].alignment = c_c_alignment
|
||||||
ws['B' + str(per_unit_area_start_row_number + 1)] = '报告期'
|
ws['B' + str(per_unit_area_start_row_number + 1)] = '报告期'
|
||||||
ws['B' + str(per_unit_area_start_row_number + 1)].border = f_border
|
ws['B' + str(per_unit_area_start_row_number + 1)].border = f_border
|
||||||
|
|
||||||
ws['C' + str(per_unit_area_start_row_number + 1)].font = title_font
|
ws['C' + str(per_unit_area_start_row_number + 1)].font = title_font
|
||||||
ws['C' + str(per_unit_area_start_row_number + 1)].alignment = c_c_alignment
|
ws['C' + str(per_unit_area_start_row_number + 1)].alignment = c_c_alignment
|
||||||
ws['C' + str(per_unit_area_start_row_number + 1)] = '算术平均数'
|
ws['C' + str(per_unit_area_start_row_number + 1)] = '算术平均数'
|
||||||
ws['C' + str(per_unit_area_start_row_number + 1)].border = f_border
|
ws['C' + str(per_unit_area_start_row_number + 1)].border = f_border
|
||||||
|
|
||||||
ws['D' + str(per_unit_area_start_row_number + 1)].font = title_font
|
ws['D' + str(per_unit_area_start_row_number + 1)].font = title_font
|
||||||
ws['D' + str(per_unit_area_start_row_number + 1)].alignment = c_c_alignment
|
ws['D' + str(per_unit_area_start_row_number + 1)].alignment = c_c_alignment
|
||||||
ws['D' + str(per_unit_area_start_row_number + 1)] = '中位数'
|
ws['D' + str(per_unit_area_start_row_number + 1)] = '中位数'
|
||||||
ws['D' + str(per_unit_area_start_row_number + 1)].border = f_border
|
ws['D' + str(per_unit_area_start_row_number + 1)].border = f_border
|
||||||
|
|
||||||
ws['E' + str(per_unit_area_start_row_number + 1)].font = title_font
|
ws['E' + str(per_unit_area_start_row_number + 1)].font = title_font
|
||||||
ws['E' + str(per_unit_area_start_row_number + 1)].alignment = c_c_alignment
|
ws['E' + str(per_unit_area_start_row_number + 1)].alignment = c_c_alignment
|
||||||
ws['E' + str(per_unit_area_start_row_number + 1)] = '最小值'
|
ws['E' + str(per_unit_area_start_row_number + 1)] = '最小值'
|
||||||
ws['E' + str(per_unit_area_start_row_number + 1)].border = f_border
|
ws['E' + str(per_unit_area_start_row_number + 1)].border = f_border
|
||||||
|
|
||||||
ws['F' + str(per_unit_area_start_row_number + 1)].font = title_font
|
ws['F' + str(per_unit_area_start_row_number + 1)].font = title_font
|
||||||
ws['F' + str(per_unit_area_start_row_number + 1)].alignment = c_c_alignment
|
ws['F' + str(per_unit_area_start_row_number + 1)].alignment = c_c_alignment
|
||||||
ws['F' + str(per_unit_area_start_row_number + 1)] = '最大值'
|
ws['F' + str(per_unit_area_start_row_number + 1)] = '最大值'
|
||||||
ws['F' + str(per_unit_area_start_row_number + 1)].border = f_border
|
ws['F' + str(per_unit_area_start_row_number + 1)].border = f_border
|
||||||
|
|
||||||
ws['G' + str(per_unit_area_start_row_number + 1)].font = title_font
|
ws['G' + str(per_unit_area_start_row_number + 1)].font = title_font
|
||||||
ws['G' + str(per_unit_area_start_row_number + 1)].alignment = c_c_alignment
|
ws['G' + str(per_unit_area_start_row_number + 1)].alignment = c_c_alignment
|
||||||
ws['G' + str(per_unit_area_start_row_number + 1)] = '样本标准差'
|
ws['G' + str(per_unit_area_start_row_number + 1)] = '样本标准差'
|
||||||
ws['G' + str(per_unit_area_start_row_number + 1)].border = f_border
|
ws['G' + str(per_unit_area_start_row_number + 1)].border = f_border
|
||||||
|
|
||||||
ws['H' + str(per_unit_area_start_row_number + 1)].font = title_font
|
ws['H' + str(per_unit_area_start_row_number + 1)].font = title_font
|
||||||
ws['H' + str(per_unit_area_start_row_number + 1)].alignment = c_c_alignment
|
ws['H' + str(per_unit_area_start_row_number + 1)].alignment = c_c_alignment
|
||||||
ws['H' + str(per_unit_area_start_row_number + 1)] = '样本方差'
|
ws['H' + str(per_unit_area_start_row_number + 1)] = '样本方差'
|
||||||
ws['H' + str(per_unit_area_start_row_number + 1)].border = f_border
|
ws['H' + str(per_unit_area_start_row_number + 1)].border = f_border
|
||||||
|
|
||||||
# table_data
|
# table_data
|
||||||
|
|
||||||
for i, value in enumerate(category):
|
for i, value in enumerate(category):
|
||||||
row_data = per_unit_area_start_row_number + 2 + i
|
row_data = per_unit_area_start_row_number + 2 + i
|
||||||
ws['B' + str(row_data)].font = name_font
|
ws['B' + str(row_data)].font = name_font
|
||||||
ws['B' + str(row_data)].alignment = c_c_alignment
|
ws['B' + str(row_data)].alignment = c_c_alignment
|
||||||
ws['B' + str(row_data)] = reporting_period_data['names'][i] + " (" + reporting_period_data['units'][
|
ws['B' + str(row_data)] = reporting_period_data['names'][i] + " (" + reporting_period_data['units'][
|
||||||
i] + "/M²)"
|
i] + "/M²)"
|
||||||
ws['B' + str(row_data)].border = f_border
|
ws['B' + str(row_data)].border = f_border
|
||||||
|
|
||||||
ws['C' + str(row_data)].font = name_font
|
ws['C' + str(row_data)].font = name_font
|
||||||
ws['C' + str(row_data)].alignment = c_c_alignment
|
ws['C' + str(row_data)].alignment = c_c_alignment
|
||||||
if reporting_period_data['means_per_unit_area'][i] \
|
if reporting_period_data['means_per_unit_area'][i] \
|
||||||
or reporting_period_data['means_per_unit_area'][i] == 0:
|
or reporting_period_data['means_per_unit_area'][i] == 0:
|
||||||
ws['C' + str(row_data)] = round(reporting_period_data['means_per_unit_area'][i], 2)
|
ws['C' + str(row_data)] = round(reporting_period_data['means_per_unit_area'][i], 2)
|
||||||
ws['C' + str(row_data)].border = f_border
|
ws['C' + str(row_data)].border = f_border
|
||||||
ws['C' + str(row_data)].number_format = '0.00'
|
ws['C' + str(row_data)].number_format = '0.00'
|
||||||
|
|
||||||
ws['D' + str(row_data)].font = name_font
|
ws['D' + str(row_data)].font = name_font
|
||||||
ws['D' + str(row_data)].alignment = c_c_alignment
|
ws['D' + str(row_data)].alignment = c_c_alignment
|
||||||
if reporting_period_data['medians_per_unit_area'][i] \
|
if reporting_period_data['medians_per_unit_area'][i] \
|
||||||
or reporting_period_data['medians_per_unit_area'][i] == 0:
|
or reporting_period_data['medians_per_unit_area'][i] == 0:
|
||||||
ws['D' + str(row_data)] = round(reporting_period_data['medians_per_unit_area'][i], 2)
|
ws['D' + str(row_data)] = round(reporting_period_data['medians_per_unit_area'][i], 2)
|
||||||
ws['D' + str(row_data)].border = f_border
|
ws['D' + str(row_data)].border = f_border
|
||||||
ws['D' + str(row_data)].number_format = '0.00'
|
ws['D' + str(row_data)].number_format = '0.00'
|
||||||
|
|
||||||
ws['E' + str(row_data)].font = name_font
|
ws['E' + str(row_data)].font = name_font
|
||||||
ws['E' + str(row_data)].alignment = c_c_alignment
|
ws['E' + str(row_data)].alignment = c_c_alignment
|
||||||
if reporting_period_data['minimums_per_unit_area'][i] \
|
if reporting_period_data['minimums_per_unit_area'][i] \
|
||||||
or reporting_period_data['minimums_per_unit_area'][i] == 0:
|
or reporting_period_data['minimums_per_unit_area'][i] == 0:
|
||||||
ws['E' + str(row_data)] = round(reporting_period_data['minimums_per_unit_area'][i], 2)
|
ws['E' + str(row_data)] = round(reporting_period_data['minimums_per_unit_area'][i], 2)
|
||||||
ws['E' + str(row_data)].border = f_border
|
ws['E' + str(row_data)].border = f_border
|
||||||
ws['E' + str(row_data)].number_format = '0.00'
|
ws['E' + str(row_data)].number_format = '0.00'
|
||||||
|
|
||||||
ws['F' + str(row_data)].font = name_font
|
ws['F' + str(row_data)].font = name_font
|
||||||
ws['F' + str(row_data)].alignment = c_c_alignment
|
ws['F' + str(row_data)].alignment = c_c_alignment
|
||||||
if reporting_period_data['maximums_per_unit_area'][i] \
|
if reporting_period_data['maximums_per_unit_area'][i] \
|
||||||
or reporting_period_data['maximums_per_unit_area'][i] == 0:
|
or reporting_period_data['maximums_per_unit_area'][i] == 0:
|
||||||
ws['F' + str(row_data)] = round(reporting_period_data['maximums_per_unit_area'][i], 2)
|
ws['F' + str(row_data)] = round(reporting_period_data['maximums_per_unit_area'][i], 2)
|
||||||
ws['F' + str(row_data)].border = f_border
|
ws['F' + str(row_data)].border = f_border
|
||||||
ws['F' + str(row_data)].number_format = '0.00'
|
ws['F' + str(row_data)].number_format = '0.00'
|
||||||
|
|
||||||
ws['G' + str(row_data)].font = name_font
|
ws['G' + str(row_data)].font = name_font
|
||||||
ws['G' + str(row_data)].alignment = c_c_alignment
|
ws['G' + str(row_data)].alignment = c_c_alignment
|
||||||
if (reporting_period_data['stdevs_per_unit_area'][i]) \
|
if (reporting_period_data['stdevs_per_unit_area'][i]) \
|
||||||
or reporting_period_data['stdevs_per_unit_area'][i] == 0:
|
or reporting_period_data['stdevs_per_unit_area'][i] == 0:
|
||||||
ws['G' + str(row_data)] = round(reporting_period_data['stdevs_per_unit_area'][i], 2)
|
ws['G' + str(row_data)] = round(reporting_period_data['stdevs_per_unit_area'][i], 2)
|
||||||
ws['G' + str(row_data)].border = f_border
|
ws['G' + str(row_data)].border = f_border
|
||||||
ws['G' + str(row_data)].number_format = '0.00'
|
ws['G' + str(row_data)].number_format = '0.00'
|
||||||
|
|
||||||
ws['H' + str(row_data)].font = name_font
|
ws['H' + str(row_data)].font = name_font
|
||||||
ws['H' + str(row_data)].alignment = c_c_alignment
|
ws['H' + str(row_data)].alignment = c_c_alignment
|
||||||
if reporting_period_data['variances_per_unit_area'][i] \
|
if reporting_period_data['variances_per_unit_area'][i] \
|
||||||
or reporting_period_data['variances_per_unit_area'][i] == 0:
|
or reporting_period_data['variances_per_unit_area'][i] == 0:
|
||||||
ws['H' + str(row_data)] = round(reporting_period_data['variances_per_unit_area'][i], 2)
|
ws['H' + str(row_data)] = round(reporting_period_data['variances_per_unit_area'][i], 2)
|
||||||
ws['H' + str(row_data)].border = f_border
|
ws['H' + str(row_data)].border = f_border
|
||||||
ws['H' + str(row_data)].number_format = '0.00'
|
ws['H' + str(row_data)].number_format = '0.00'
|
||||||
|
|
||||||
####################################################################################################################
|
####################################################################################################################
|
||||||
# Third: 详细数据
|
# Third: 详细数据
|
||||||
|
|
|
@ -2,11 +2,7 @@ import base64
|
||||||
import uuid
|
import uuid
|
||||||
import os
|
import os
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
from openpyxl.chart import (
|
from openpyxl.chart import PieChart, LineChart, Reference
|
||||||
PieChart,
|
|
||||||
LineChart,
|
|
||||||
Reference,
|
|
||||||
)
|
|
||||||
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
||||||
from openpyxl.drawing.image import Image
|
from openpyxl.drawing.image import Image
|
||||||
from openpyxl import Workbook
|
from openpyxl import Workbook
|
||||||
|
|
|
@ -1,12 +1,7 @@
|
||||||
import base64
|
import base64
|
||||||
import uuid
|
import uuid
|
||||||
import os
|
import os
|
||||||
from openpyxl.chart import (
|
from openpyxl.chart import LineChart, Reference
|
||||||
PieChart,
|
|
||||||
LineChart,
|
|
||||||
BarChart,
|
|
||||||
Reference,
|
|
||||||
)
|
|
||||||
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
||||||
from openpyxl.drawing.image import Image
|
from openpyxl.drawing.image import Image
|
||||||
from openpyxl import Workbook
|
from openpyxl import Workbook
|
||||||
|
|
|
@ -1,12 +1,7 @@
|
||||||
import base64
|
import base64
|
||||||
import uuid
|
import uuid
|
||||||
import os
|
import os
|
||||||
from openpyxl.chart import (
|
from openpyxl.chart import PieChart, LineChart, Reference
|
||||||
PieChart,
|
|
||||||
LineChart,
|
|
||||||
BarChart,
|
|
||||||
Reference,
|
|
||||||
)
|
|
||||||
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
||||||
from openpyxl.drawing.image import Image
|
from openpyxl.drawing.image import Image
|
||||||
from openpyxl import Workbook
|
from openpyxl import Workbook
|
||||||
|
@ -119,12 +114,6 @@ def generate_excel(report,
|
||||||
wrap_text=True,
|
wrap_text=True,
|
||||||
shrink_to_fit=False,
|
shrink_to_fit=False,
|
||||||
indent=0)
|
indent=0)
|
||||||
c_r_alignment = Alignment(vertical='bottom',
|
|
||||||
horizontal='center',
|
|
||||||
text_rotation=0,
|
|
||||||
wrap_text=True,
|
|
||||||
shrink_to_fit=False,
|
|
||||||
indent=0)
|
|
||||||
|
|
||||||
# Img
|
# Img
|
||||||
img = Image("excelexporters/myems.png")
|
img = Image("excelexporters/myems.png")
|
||||||
|
|
|
@ -1,12 +1,7 @@
|
||||||
import base64
|
import base64
|
||||||
import uuid
|
import uuid
|
||||||
import os
|
import os
|
||||||
from openpyxl.chart import (
|
from openpyxl.chart import PieChart, LineChart, Reference
|
||||||
PieChart,
|
|
||||||
LineChart,
|
|
||||||
BarChart,
|
|
||||||
Reference,
|
|
||||||
)
|
|
||||||
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
||||||
from openpyxl.drawing.image import Image
|
from openpyxl.drawing.image import Image
|
||||||
from openpyxl import Workbook
|
from openpyxl import Workbook
|
||||||
|
|
|
@ -2,12 +2,7 @@ import base64
|
||||||
import uuid
|
import uuid
|
||||||
import os
|
import os
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
from openpyxl.chart import (
|
from openpyxl.chart import PieChart, LineChart, Reference
|
||||||
PieChart,
|
|
||||||
LineChart,
|
|
||||||
BarChart,
|
|
||||||
Reference,
|
|
||||||
)
|
|
||||||
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
||||||
from openpyxl.drawing.image import Image
|
from openpyxl.drawing.image import Image
|
||||||
from openpyxl import Workbook
|
from openpyxl import Workbook
|
||||||
|
|
|
@ -1,12 +1,7 @@
|
||||||
import base64
|
import base64
|
||||||
import uuid
|
import uuid
|
||||||
import os
|
import os
|
||||||
from openpyxl.chart import (
|
from openpyxl.chart import LineChart, Reference
|
||||||
PieChart,
|
|
||||||
LineChart,
|
|
||||||
BarChart,
|
|
||||||
Reference,
|
|
||||||
)
|
|
||||||
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
||||||
from openpyxl.drawing.image import Image
|
from openpyxl.drawing.image import Image
|
||||||
from openpyxl import Workbook
|
from openpyxl import Workbook
|
||||||
|
|
|
@ -1,12 +1,7 @@
|
||||||
import base64
|
import base64
|
||||||
import uuid
|
import uuid
|
||||||
import os
|
import os
|
||||||
from openpyxl.chart import (
|
from openpyxl.chart import PieChart, LineChart, Reference
|
||||||
PieChart,
|
|
||||||
LineChart,
|
|
||||||
BarChart,
|
|
||||||
Reference,
|
|
||||||
)
|
|
||||||
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
||||||
from openpyxl.drawing.image import Image
|
from openpyxl.drawing.image import Image
|
||||||
from openpyxl import Workbook
|
from openpyxl import Workbook
|
||||||
|
|
|
@ -1,12 +1,8 @@
|
||||||
import base64
|
import base64
|
||||||
import uuid
|
import uuid
|
||||||
import os
|
import os
|
||||||
from openpyxl.chart import (
|
from decimal import Decimal
|
||||||
PieChart,
|
from openpyxl.chart import PieChart, LineChart, Reference
|
||||||
LineChart,
|
|
||||||
BarChart,
|
|
||||||
Reference,
|
|
||||||
)
|
|
||||||
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
||||||
from openpyxl.drawing.image import Image
|
from openpyxl.drawing.image import Image
|
||||||
from openpyxl import Workbook
|
from openpyxl import Workbook
|
||||||
|
@ -868,7 +864,7 @@ def generate_excel(report,
|
||||||
|
|
||||||
|
|
||||||
def sum_list(lists):
|
def sum_list(lists):
|
||||||
total = 0
|
total = Decimal(0)
|
||||||
|
|
||||||
for i in range(0, len(lists)):
|
for i in range(0, len(lists)):
|
||||||
total += lists[i]
|
total += lists[i]
|
||||||
|
|
|
@ -1,10 +1,7 @@
|
||||||
import base64
|
import base64
|
||||||
import uuid
|
import uuid
|
||||||
import os
|
import os
|
||||||
from openpyxl.chart import (
|
from openpyxl.chart import LineChart, Reference
|
||||||
LineChart,
|
|
||||||
Reference,
|
|
||||||
)
|
|
||||||
from openpyxl.chart.label import DataLabelList
|
from openpyxl.chart.label import DataLabelList
|
||||||
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
||||||
from openpyxl.drawing.image import Image
|
from openpyxl.drawing.image import Image
|
||||||
|
@ -160,152 +157,146 @@ def generate_excel(report,
|
||||||
####################################################################################################################
|
####################################################################################################################
|
||||||
reporting_period_data = report['reporting_period']
|
reporting_period_data = report['reporting_period']
|
||||||
|
|
||||||
has_energy_data_flag = True
|
|
||||||
|
|
||||||
if "names" not in reporting_period_data.keys() or \
|
if "names" not in reporting_period_data.keys() or \
|
||||||
reporting_period_data['names'] is None or \
|
reporting_period_data['names'] is None or \
|
||||||
len(reporting_period_data['names']) == 0:
|
len(reporting_period_data['names']) == 0:
|
||||||
has_energy_data_flag = False
|
|
||||||
|
|
||||||
filename = str(uuid.uuid4()) + '.xlsx'
|
filename = str(uuid.uuid4()) + '.xlsx'
|
||||||
wb.save(filename)
|
wb.save(filename)
|
||||||
|
|
||||||
return filename
|
return filename
|
||||||
|
|
||||||
if has_energy_data_flag:
|
ws['B6'].font = title_font
|
||||||
ws['B6'].font = title_font
|
ws['B6'] = name + ' 统计分析'
|
||||||
ws['B6'] = name + ' 统计分析'
|
|
||||||
|
|
||||||
category = reporting_period_data['names']
|
category = reporting_period_data['names']
|
||||||
|
|
||||||
# table_title
|
# table_title
|
||||||
ws['B7'].fill = table_fill
|
ws['B7'].fill = table_fill
|
||||||
ws['B7'].font = title_font
|
ws['B7'].font = title_font
|
||||||
ws['B7'].alignment = c_c_alignment
|
ws['B7'].alignment = c_c_alignment
|
||||||
ws['B7'] = '报告期'
|
ws['B7'] = '报告期'
|
||||||
ws['B7'].border = f_border
|
ws['B7'].border = f_border
|
||||||
|
|
||||||
ws['C7'].font = title_font
|
ws['C7'].font = title_font
|
||||||
ws['C7'].alignment = c_c_alignment
|
ws['C7'].alignment = c_c_alignment
|
||||||
ws['C7'] = '算术平均数'
|
ws['C7'] = '算术平均数'
|
||||||
ws['C7'].border = f_border
|
ws['C7'].border = f_border
|
||||||
|
|
||||||
ws['D7'].font = title_font
|
ws['D7'].font = title_font
|
||||||
ws['D7'].alignment = c_c_alignment
|
ws['D7'].alignment = c_c_alignment
|
||||||
ws['D7'] = '中位数'
|
ws['D7'] = '中位数'
|
||||||
ws['D7'].border = f_border
|
ws['D7'].border = f_border
|
||||||
|
|
||||||
ws['E7'].font = title_font
|
ws['E7'].font = title_font
|
||||||
ws['E7'].alignment = c_c_alignment
|
ws['E7'].alignment = c_c_alignment
|
||||||
ws['E7'] = '最小值'
|
ws['E7'] = '最小值'
|
||||||
ws['E7'].border = f_border
|
ws['E7'].border = f_border
|
||||||
|
|
||||||
ws['F7'].font = title_font
|
ws['F7'].font = title_font
|
||||||
ws['F7'].alignment = c_c_alignment
|
ws['F7'].alignment = c_c_alignment
|
||||||
ws['F7'] = '最大值'
|
ws['F7'] = '最大值'
|
||||||
ws['F7'].border = f_border
|
ws['F7'].border = f_border
|
||||||
|
|
||||||
ws['G7'].font = title_font
|
ws['G7'].font = title_font
|
||||||
ws['G7'].alignment = c_c_alignment
|
ws['G7'].alignment = c_c_alignment
|
||||||
ws['G7'] = '样本标准差'
|
ws['G7'] = '样本标准差'
|
||||||
ws['G7'].border = f_border
|
ws['G7'].border = f_border
|
||||||
|
|
||||||
ws['H7'].font = title_font
|
ws['H7'].font = title_font
|
||||||
ws['H7'].alignment = c_c_alignment
|
ws['H7'].alignment = c_c_alignment
|
||||||
ws['H7'] = '样本方差'
|
ws['H7'] = '样本方差'
|
||||||
ws['H7'].border = f_border
|
ws['H7'].border = f_border
|
||||||
|
|
||||||
# table_data
|
# table_data
|
||||||
|
|
||||||
for i, value in enumerate(category):
|
for i, value in enumerate(category):
|
||||||
row = i*2 + 8
|
row = i*2 + 8
|
||||||
ws['B' + str(row)].font = name_font
|
ws['B' + str(row)].font = name_font
|
||||||
ws['B' + str(row)].alignment = c_c_alignment
|
ws['B' + str(row)].alignment = c_c_alignment
|
||||||
ws['B' + str(row)] = reporting_period_data['names'][i] + " (" + reporting_period_data['units'][i] + " )"
|
ws['B' + str(row)] = reporting_period_data['names'][i] + " (" + reporting_period_data['units'][i] + " )"
|
||||||
ws['B' + str(row)].border = f_border
|
ws['B' + str(row)].border = f_border
|
||||||
|
|
||||||
ws['B' + str(row + 1)].font = name_font
|
ws['B' + str(row + 1)].font = name_font
|
||||||
ws['B' + str(row + 1)].alignment = c_c_alignment
|
ws['B' + str(row + 1)].alignment = c_c_alignment
|
||||||
ws['B' + str(row + 1)] = "环比"
|
ws['B' + str(row + 1)] = "环比"
|
||||||
ws['B' + str(row + 1)].border = f_border
|
ws['B' + str(row + 1)].border = f_border
|
||||||
|
|
||||||
ws['C' + str(row)].font = name_font
|
ws['C' + str(row)].font = name_font
|
||||||
ws['C' + str(row)].alignment = c_c_alignment
|
ws['C' + str(row)].alignment = c_c_alignment
|
||||||
ws['C' + str(row)] = round(reporting_period_data['means'][i], 2) \
|
ws['C' + str(row)] = round(reporting_period_data['means'][i], 2) \
|
||||||
if reporting_period_data['means'][i] is not None else ''
|
if reporting_period_data['means'][i] is not None else ''
|
||||||
ws['C' + str(row)].border = f_border
|
ws['C' + str(row)].border = f_border
|
||||||
ws['C' + str(row)].number_format = '0.00'
|
ws['C' + str(row)].number_format = '0.00'
|
||||||
|
|
||||||
ws['C' + str(row + 1)].font = name_font
|
ws['C' + str(row + 1)].font = name_font
|
||||||
ws['C' + str(row + 1)].alignment = c_c_alignment
|
ws['C' + str(row + 1)].alignment = c_c_alignment
|
||||||
ws['C' + str(row + 1)] = str(round(reporting_period_data['means_increment_rate'][i] * 100, 2)) + "%" \
|
ws['C' + str(row + 1)] = str(round(reporting_period_data['means_increment_rate'][i] * 100, 2)) + "%" \
|
||||||
if reporting_period_data['means_increment_rate'][i] is not None else '0.00%'
|
if reporting_period_data['means_increment_rate'][i] is not None else '0.00%'
|
||||||
ws['C' + str(row + 1)].border = f_border
|
ws['C' + str(row + 1)].border = f_border
|
||||||
|
|
||||||
ws['D' + str(row)].font = name_font
|
ws['D' + str(row)].font = name_font
|
||||||
ws['D' + str(row)].alignment = c_c_alignment
|
ws['D' + str(row)].alignment = c_c_alignment
|
||||||
ws['D' + str(row)] = round(reporting_period_data['medians'][i], 2) \
|
ws['D' + str(row)] = round(reporting_period_data['medians'][i], 2) \
|
||||||
if reporting_period_data['medians'][i] is not None else ''
|
if reporting_period_data['medians'][i] is not None else ''
|
||||||
ws['D' + str(row)].border = f_border
|
ws['D' + str(row)].border = f_border
|
||||||
ws['D' + str(row)].number_format = '0.00'
|
ws['D' + str(row)].number_format = '0.00'
|
||||||
|
|
||||||
ws['D' + str(row + 1)].font = name_font
|
ws['D' + str(row + 1)].font = name_font
|
||||||
ws['D' + str(row + 1)].alignment = c_c_alignment
|
ws['D' + str(row + 1)].alignment = c_c_alignment
|
||||||
ws['D' + str(row + 1)] = str(round(reporting_period_data['medians_increment_rate'][i] * 100, 2)) + "%" \
|
ws['D' + str(row + 1)] = str(round(reporting_period_data['medians_increment_rate'][i] * 100, 2)) + "%" \
|
||||||
if reporting_period_data['medians_increment_rate'][i] is not None else '0.00%'
|
if reporting_period_data['medians_increment_rate'][i] is not None else '0.00%'
|
||||||
ws['D' + str(row + 1)].border = f_border
|
ws['D' + str(row + 1)].border = f_border
|
||||||
|
|
||||||
ws['E' + str(row)].font = name_font
|
ws['E' + str(row)].font = name_font
|
||||||
ws['E' + str(row)].alignment = c_c_alignment
|
ws['E' + str(row)].alignment = c_c_alignment
|
||||||
ws['E' + str(row)] = round(reporting_period_data['minimums'][i], 2) \
|
ws['E' + str(row)] = round(reporting_period_data['minimums'][i], 2) \
|
||||||
if reporting_period_data['minimums'][i] is not None else ''
|
if reporting_period_data['minimums'][i] is not None else ''
|
||||||
ws['E' + str(row)].border = f_border
|
ws['E' + str(row)].border = f_border
|
||||||
ws['E' + str(row)].number_format = '0.00'
|
ws['E' + str(row)].number_format = '0.00'
|
||||||
|
|
||||||
ws['E' + str(row + 1)].font = name_font
|
ws['E' + str(row + 1)].font = name_font
|
||||||
ws['E' + str(row + 1)].alignment = c_c_alignment
|
ws['E' + str(row + 1)].alignment = c_c_alignment
|
||||||
ws['E' + str(row + 1)] = str(round(reporting_period_data['minimums_increment_rate'][i] * 100, 2)) + "%" \
|
ws['E' + str(row + 1)] = str(round(reporting_period_data['minimums_increment_rate'][i] * 100, 2)) + "%" \
|
||||||
if reporting_period_data['minimums_increment_rate'][i] is not None else '0.00%'
|
if reporting_period_data['minimums_increment_rate'][i] is not None else '0.00%'
|
||||||
ws['E' + str(row + 1)].border = f_border
|
ws['E' + str(row + 1)].border = f_border
|
||||||
|
|
||||||
ws['F' + str(row)].font = name_font
|
ws['F' + str(row)].font = name_font
|
||||||
ws['F' + str(row)].alignment = c_c_alignment
|
ws['F' + str(row)].alignment = c_c_alignment
|
||||||
ws['F' + str(row)] = round(reporting_period_data['maximums'][i], 2) \
|
ws['F' + str(row)] = round(reporting_period_data['maximums'][i], 2) \
|
||||||
if reporting_period_data['maximums'][i] is not None else ''
|
if reporting_period_data['maximums'][i] is not None else ''
|
||||||
ws['F' + str(row)].border = f_border
|
ws['F' + str(row)].border = f_border
|
||||||
ws['F' + str(row)].number_format = '0.00'
|
ws['F' + str(row)].number_format = '0.00'
|
||||||
|
|
||||||
ws['F' + str(row + 1)].font = name_font
|
ws['F' + str(row + 1)].font = name_font
|
||||||
ws['F' + str(row + 1)].alignment = c_c_alignment
|
ws['F' + str(row + 1)].alignment = c_c_alignment
|
||||||
ws['F' + str(row + 1)] = str(round(reporting_period_data['maximums_increment_rate'][i] * 100, 2)) + "%" \
|
ws['F' + str(row + 1)] = str(round(reporting_period_data['maximums_increment_rate'][i] * 100, 2)) + "%" \
|
||||||
if reporting_period_data['maximums_increment_rate'][i] is not None else '0.00%'
|
if reporting_period_data['maximums_increment_rate'][i] is not None else '0.00%'
|
||||||
ws['F' + str(row + 1)].border = f_border
|
ws['F' + str(row + 1)].border = f_border
|
||||||
|
|
||||||
ws['G' + str(row)].font = name_font
|
ws['G' + str(row)].font = name_font
|
||||||
ws['G' + str(row)].alignment = c_c_alignment
|
ws['G' + str(row)].alignment = c_c_alignment
|
||||||
ws['G' + str(row)] = round(reporting_period_data['stdevs'][i], 2) \
|
ws['G' + str(row)] = round(reporting_period_data['stdevs'][i], 2) \
|
||||||
if reporting_period_data['stdevs'][i] is not None else ''
|
if reporting_period_data['stdevs'][i] is not None else ''
|
||||||
ws['G' + str(row)].border = f_border
|
ws['G' + str(row)].border = f_border
|
||||||
ws['G' + str(row)].number_format = '0.00'
|
ws['G' + str(row)].number_format = '0.00'
|
||||||
|
|
||||||
ws['G' + str(row + 1)].font = name_font
|
ws['G' + str(row + 1)].font = name_font
|
||||||
ws['G' + str(row + 1)].alignment = c_c_alignment
|
ws['G' + str(row + 1)].alignment = c_c_alignment
|
||||||
ws['G' + str(row + 1)] = str(round(reporting_period_data['stdevs_increment_rate'][i] * 100, 2)) + "%" \
|
ws['G' + str(row + 1)] = str(round(reporting_period_data['stdevs_increment_rate'][i] * 100, 2)) + "%" \
|
||||||
if reporting_period_data['stdevs_increment_rate'][i] is not None else '0.00%'
|
if reporting_period_data['stdevs_increment_rate'][i] is not None else '0.00%'
|
||||||
ws['G' + str(row + 1)].border = f_border
|
ws['G' + str(row + 1)].border = f_border
|
||||||
|
|
||||||
ws['H' + str(row)].font = name_font
|
ws['H' + str(row)].font = name_font
|
||||||
ws['H' + str(row)].alignment = c_c_alignment
|
ws['H' + str(row)].alignment = c_c_alignment
|
||||||
ws['H' + str(row)] = round(reporting_period_data['variances'][i], 2) \
|
ws['H' + str(row)] = round(reporting_period_data['variances'][i], 2) \
|
||||||
if reporting_period_data['variances'][i] is not None else ''
|
if reporting_period_data['variances'][i] is not None else ''
|
||||||
ws['H' + str(row)].border = f_border
|
ws['H' + str(row)].border = f_border
|
||||||
ws['H' + str(row)].number_format = '0.00'
|
ws['H' + str(row)].number_format = '0.00'
|
||||||
|
|
||||||
ws['H' + str(row + 1)].font = name_font
|
ws['H' + str(row + 1)].font = name_font
|
||||||
ws['H' + str(row + 1)].alignment = c_c_alignment
|
ws['H' + str(row + 1)].alignment = c_c_alignment
|
||||||
ws['H' + str(row + 1)] = str(round(reporting_period_data['variances_increment_rate'][i] * 100, 2)) + "%" \
|
ws['H' + str(row + 1)] = str(round(reporting_period_data['variances_increment_rate'][i] * 100, 2)) + "%" \
|
||||||
if reporting_period_data['variances_increment_rate'][i] is not None else '0.00%'
|
if reporting_period_data['variances_increment_rate'][i] is not None else '0.00%'
|
||||||
ws['H' + str(row + 1)].border = f_border
|
ws['H' + str(row + 1)].border = f_border
|
||||||
####################################################################################################################
|
####################################################################################################################
|
||||||
# Second: 报告期消耗
|
# Second: 报告期消耗
|
||||||
# 9 + ca_len * 2: title
|
# 9 + ca_len * 2: title
|
||||||
|
@ -313,113 +304,112 @@ def generate_excel(report,
|
||||||
# per_unit_area_start_row_number + 2 ~ per_unit_area_start_row_number + 2 + ca_len : table_data
|
# per_unit_area_start_row_number + 2 ~ per_unit_area_start_row_number + 2 + ca_len : table_data
|
||||||
####################################################################################################################
|
####################################################################################################################
|
||||||
|
|
||||||
if has_energy_data_flag:
|
names = reporting_period_data['names']
|
||||||
names = reporting_period_data['names']
|
ca_len = len(names)
|
||||||
ca_len = len(names)
|
|
||||||
|
|
||||||
per_unit_area_start_row_number = 9 + ca_len * 2
|
per_unit_area_start_row_number = 9 + ca_len * 2
|
||||||
|
|
||||||
ws['B' + str(per_unit_area_start_row_number)].font = title_font
|
ws['B' + str(per_unit_area_start_row_number)].font = title_font
|
||||||
ws['B' + str(per_unit_area_start_row_number)] = name + ' 单位面积值'
|
ws['B' + str(per_unit_area_start_row_number)] = name + ' 单位面积值'
|
||||||
ws['D' + str(per_unit_area_start_row_number)].font = title_font
|
ws['D' + str(per_unit_area_start_row_number)].font = title_font
|
||||||
ws['D' + str(per_unit_area_start_row_number)] = str(report['space']['area']) + 'M²'
|
ws['D' + str(per_unit_area_start_row_number)] = str(report['space']['area']) + 'M²'
|
||||||
|
|
||||||
category = reporting_period_data['names']
|
category = reporting_period_data['names']
|
||||||
|
|
||||||
# table_title
|
# table_title
|
||||||
ws['B' + str(per_unit_area_start_row_number + 1)].fill = table_fill
|
ws['B' + str(per_unit_area_start_row_number + 1)].fill = table_fill
|
||||||
ws['B' + str(per_unit_area_start_row_number + 1)].font = title_font
|
ws['B' + str(per_unit_area_start_row_number + 1)].font = title_font
|
||||||
ws['B' + str(per_unit_area_start_row_number + 1)].alignment = c_c_alignment
|
ws['B' + str(per_unit_area_start_row_number + 1)].alignment = c_c_alignment
|
||||||
ws['B' + str(per_unit_area_start_row_number + 1)] = '报告期'
|
ws['B' + str(per_unit_area_start_row_number + 1)] = '报告期'
|
||||||
ws['B' + str(per_unit_area_start_row_number + 1)].border = f_border
|
ws['B' + str(per_unit_area_start_row_number + 1)].border = f_border
|
||||||
|
|
||||||
ws['C' + str(per_unit_area_start_row_number + 1)].font = title_font
|
ws['C' + str(per_unit_area_start_row_number + 1)].font = title_font
|
||||||
ws['C' + str(per_unit_area_start_row_number + 1)].alignment = c_c_alignment
|
ws['C' + str(per_unit_area_start_row_number + 1)].alignment = c_c_alignment
|
||||||
ws['C' + str(per_unit_area_start_row_number + 1)] = '算术平均数'
|
ws['C' + str(per_unit_area_start_row_number + 1)] = '算术平均数'
|
||||||
ws['C' + str(per_unit_area_start_row_number + 1)].border = f_border
|
ws['C' + str(per_unit_area_start_row_number + 1)].border = f_border
|
||||||
|
|
||||||
ws['D' + str(per_unit_area_start_row_number + 1)].font = title_font
|
ws['D' + str(per_unit_area_start_row_number + 1)].font = title_font
|
||||||
ws['D' + str(per_unit_area_start_row_number + 1)].alignment = c_c_alignment
|
ws['D' + str(per_unit_area_start_row_number + 1)].alignment = c_c_alignment
|
||||||
ws['D' + str(per_unit_area_start_row_number + 1)] = '中位数'
|
ws['D' + str(per_unit_area_start_row_number + 1)] = '中位数'
|
||||||
ws['D' + str(per_unit_area_start_row_number + 1)].border = f_border
|
ws['D' + str(per_unit_area_start_row_number + 1)].border = f_border
|
||||||
|
|
||||||
ws['E' + str(per_unit_area_start_row_number + 1)].font = title_font
|
ws['E' + str(per_unit_area_start_row_number + 1)].font = title_font
|
||||||
ws['E' + str(per_unit_area_start_row_number + 1)].alignment = c_c_alignment
|
ws['E' + str(per_unit_area_start_row_number + 1)].alignment = c_c_alignment
|
||||||
ws['E' + str(per_unit_area_start_row_number + 1)] = '最小值'
|
ws['E' + str(per_unit_area_start_row_number + 1)] = '最小值'
|
||||||
ws['E' + str(per_unit_area_start_row_number + 1)].border = f_border
|
ws['E' + str(per_unit_area_start_row_number + 1)].border = f_border
|
||||||
|
|
||||||
ws['F' + str(per_unit_area_start_row_number + 1)].font = title_font
|
ws['F' + str(per_unit_area_start_row_number + 1)].font = title_font
|
||||||
ws['F' + str(per_unit_area_start_row_number + 1)].alignment = c_c_alignment
|
ws['F' + str(per_unit_area_start_row_number + 1)].alignment = c_c_alignment
|
||||||
ws['F' + str(per_unit_area_start_row_number + 1)] = '最大值'
|
ws['F' + str(per_unit_area_start_row_number + 1)] = '最大值'
|
||||||
ws['F' + str(per_unit_area_start_row_number + 1)].border = f_border
|
ws['F' + str(per_unit_area_start_row_number + 1)].border = f_border
|
||||||
|
|
||||||
ws['G' + str(per_unit_area_start_row_number + 1)].font = title_font
|
ws['G' + str(per_unit_area_start_row_number + 1)].font = title_font
|
||||||
ws['G' + str(per_unit_area_start_row_number + 1)].alignment = c_c_alignment
|
ws['G' + str(per_unit_area_start_row_number + 1)].alignment = c_c_alignment
|
||||||
ws['G' + str(per_unit_area_start_row_number + 1)] = '样本标准差'
|
ws['G' + str(per_unit_area_start_row_number + 1)] = '样本标准差'
|
||||||
ws['G' + str(per_unit_area_start_row_number + 1)].border = f_border
|
ws['G' + str(per_unit_area_start_row_number + 1)].border = f_border
|
||||||
|
|
||||||
ws['H' + str(per_unit_area_start_row_number + 1)].font = title_font
|
ws['H' + str(per_unit_area_start_row_number + 1)].font = title_font
|
||||||
ws['H' + str(per_unit_area_start_row_number + 1)].alignment = c_c_alignment
|
ws['H' + str(per_unit_area_start_row_number + 1)].alignment = c_c_alignment
|
||||||
ws['H' + str(per_unit_area_start_row_number + 1)] = '样本方差'
|
ws['H' + str(per_unit_area_start_row_number + 1)] = '样本方差'
|
||||||
ws['H' + str(per_unit_area_start_row_number + 1)].border = f_border
|
ws['H' + str(per_unit_area_start_row_number + 1)].border = f_border
|
||||||
|
|
||||||
# table_data
|
# table_data
|
||||||
|
|
||||||
for i, value in enumerate(category):
|
for i, value in enumerate(category):
|
||||||
row_data = per_unit_area_start_row_number + 2 + i
|
row_data = per_unit_area_start_row_number + 2 + i
|
||||||
ws['B' + str(row_data)].font = name_font
|
ws['B' + str(row_data)].font = name_font
|
||||||
ws['B' + str(row_data)].alignment = c_c_alignment
|
ws['B' + str(row_data)].alignment = c_c_alignment
|
||||||
ws['B' + str(row_data)] = reporting_period_data['names'][i] + " (" + reporting_period_data['units'][
|
ws['B' + str(row_data)] = reporting_period_data['names'][i] + " (" + reporting_period_data['units'][
|
||||||
i] + "/M²)"
|
i] + "/M²)"
|
||||||
ws['B' + str(row_data)].border = f_border
|
ws['B' + str(row_data)].border = f_border
|
||||||
|
|
||||||
ws['C' + str(row_data)].font = name_font
|
ws['C' + str(row_data)].font = name_font
|
||||||
ws['C' + str(row_data)].alignment = c_c_alignment
|
ws['C' + str(row_data)].alignment = c_c_alignment
|
||||||
if reporting_period_data['means_per_unit_area'][i] \
|
if reporting_period_data['means_per_unit_area'][i] \
|
||||||
or reporting_period_data['means_per_unit_area'][i] == 0:
|
or reporting_period_data['means_per_unit_area'][i] == 0:
|
||||||
ws['C' + str(row_data)] = round(reporting_period_data['means_per_unit_area'][i], 2)
|
ws['C' + str(row_data)] = round(reporting_period_data['means_per_unit_area'][i], 2)
|
||||||
ws['C' + str(row_data)].border = f_border
|
ws['C' + str(row_data)].border = f_border
|
||||||
ws['C' + str(row_data)].number_format = '0.00'
|
ws['C' + str(row_data)].number_format = '0.00'
|
||||||
|
|
||||||
ws['D' + str(row_data)].font = name_font
|
ws['D' + str(row_data)].font = name_font
|
||||||
ws['D' + str(row_data)].alignment = c_c_alignment
|
ws['D' + str(row_data)].alignment = c_c_alignment
|
||||||
if reporting_period_data['medians_per_unit_area'][i] \
|
if reporting_period_data['medians_per_unit_area'][i] \
|
||||||
or reporting_period_data['medians_per_unit_area'][i] == 0:
|
or reporting_period_data['medians_per_unit_area'][i] == 0:
|
||||||
ws['D' + str(row_data)] = round(reporting_period_data['medians_per_unit_area'][i], 2)
|
ws['D' + str(row_data)] = round(reporting_period_data['medians_per_unit_area'][i], 2)
|
||||||
ws['D' + str(row_data)].border = f_border
|
ws['D' + str(row_data)].border = f_border
|
||||||
ws['D' + str(row_data)].number_format = '0.00'
|
ws['D' + str(row_data)].number_format = '0.00'
|
||||||
|
|
||||||
ws['E' + str(row_data)].font = name_font
|
ws['E' + str(row_data)].font = name_font
|
||||||
ws['E' + str(row_data)].alignment = c_c_alignment
|
ws['E' + str(row_data)].alignment = c_c_alignment
|
||||||
if reporting_period_data['minimums_per_unit_area'][i] \
|
if reporting_period_data['minimums_per_unit_area'][i] \
|
||||||
or reporting_period_data['minimums_per_unit_area'][i] == 0:
|
or reporting_period_data['minimums_per_unit_area'][i] == 0:
|
||||||
ws['E' + str(row_data)] = round(reporting_period_data['minimums_per_unit_area'][i], 2)
|
ws['E' + str(row_data)] = round(reporting_period_data['minimums_per_unit_area'][i], 2)
|
||||||
ws['E' + str(row_data)].border = f_border
|
ws['E' + str(row_data)].border = f_border
|
||||||
ws['E' + str(row_data)].number_format = '0.00'
|
ws['E' + str(row_data)].number_format = '0.00'
|
||||||
|
|
||||||
ws['F' + str(row_data)].font = name_font
|
ws['F' + str(row_data)].font = name_font
|
||||||
ws['F' + str(row_data)].alignment = c_c_alignment
|
ws['F' + str(row_data)].alignment = c_c_alignment
|
||||||
if reporting_period_data['maximums_per_unit_area'][i] \
|
if reporting_period_data['maximums_per_unit_area'][i] \
|
||||||
or reporting_period_data['maximums_per_unit_area'][i] == 0:
|
or reporting_period_data['maximums_per_unit_area'][i] == 0:
|
||||||
ws['F' + str(row_data)] = round(reporting_period_data['maximums_per_unit_area'][i], 2)
|
ws['F' + str(row_data)] = round(reporting_period_data['maximums_per_unit_area'][i], 2)
|
||||||
ws['F' + str(row_data)].border = f_border
|
ws['F' + str(row_data)].border = f_border
|
||||||
ws['F' + str(row_data)].number_format = '0.00'
|
ws['F' + str(row_data)].number_format = '0.00'
|
||||||
|
|
||||||
ws['G' + str(row_data)].font = name_font
|
ws['G' + str(row_data)].font = name_font
|
||||||
ws['G' + str(row_data)].alignment = c_c_alignment
|
ws['G' + str(row_data)].alignment = c_c_alignment
|
||||||
if (reporting_period_data['stdevs_per_unit_area'][i]) \
|
if (reporting_period_data['stdevs_per_unit_area'][i]) \
|
||||||
or reporting_period_data['stdevs_per_unit_area'][i] == 0:
|
or reporting_period_data['stdevs_per_unit_area'][i] == 0:
|
||||||
ws['G' + str(row_data)] = round(reporting_period_data['stdevs_per_unit_area'][i], 2)
|
ws['G' + str(row_data)] = round(reporting_period_data['stdevs_per_unit_area'][i], 2)
|
||||||
ws['G' + str(row_data)].border = f_border
|
ws['G' + str(row_data)].border = f_border
|
||||||
ws['G' + str(row_data)].number_format = '0.00'
|
ws['G' + str(row_data)].number_format = '0.00'
|
||||||
|
|
||||||
ws['H' + str(row_data)].font = name_font
|
ws['H' + str(row_data)].font = name_font
|
||||||
ws['H' + str(row_data)].alignment = c_c_alignment
|
ws['H' + str(row_data)].alignment = c_c_alignment
|
||||||
if reporting_period_data['variances_per_unit_area'][i] \
|
if reporting_period_data['variances_per_unit_area'][i] \
|
||||||
or reporting_period_data['variances_per_unit_area'][i] == 0:
|
or reporting_period_data['variances_per_unit_area'][i] == 0:
|
||||||
ws['H' + str(row_data)] = round(reporting_period_data['variances_per_unit_area'][i], 2)
|
ws['H' + str(row_data)] = round(reporting_period_data['variances_per_unit_area'][i], 2)
|
||||||
ws['H' + str(row_data)].border = f_border
|
ws['H' + str(row_data)].border = f_border
|
||||||
ws['H' + str(row_data)].number_format = '0.00'
|
ws['H' + str(row_data)].number_format = '0.00'
|
||||||
|
|
||||||
####################################################################################################################
|
####################################################################################################################
|
||||||
# Third: 详细数据
|
# Third: 详细数据
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import base64
|
import base64
|
||||||
import uuid
|
import uuid
|
||||||
import os
|
import os
|
||||||
from openpyxl.styles import PatternFill, Border, Side, Alignment, Protection, Font
|
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
||||||
from openpyxl.drawing.image import Image
|
from openpyxl.drawing.image import Image
|
||||||
from openpyxl import Workbook
|
from openpyxl import Workbook
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,7 @@
|
||||||
import base64
|
import base64
|
||||||
import uuid
|
import uuid
|
||||||
import os
|
import os
|
||||||
from openpyxl.chart import (
|
from openpyxl.chart import PieChart, Reference, LineChart
|
||||||
PieChart,
|
|
||||||
BarChart,
|
|
||||||
Reference,
|
|
||||||
LineChart,
|
|
||||||
)
|
|
||||||
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
||||||
from openpyxl.drawing.image import Image
|
from openpyxl.drawing.image import Image
|
||||||
from openpyxl import Workbook
|
from openpyxl import Workbook
|
||||||
|
@ -153,7 +148,6 @@ def generate_excel(report,
|
||||||
"names" not in report['reporting_period'].keys() or len(report['reporting_period']['names']) == 0:
|
"names" not in report['reporting_period'].keys() or len(report['reporting_period']['names']) == 0:
|
||||||
filename = str(uuid.uuid4()) + '.xlsx'
|
filename = str(uuid.uuid4()) + '.xlsx'
|
||||||
wb.save(filename)
|
wb.save(filename)
|
||||||
|
|
||||||
return filename
|
return filename
|
||||||
|
|
||||||
####################################################################################################################
|
####################################################################################################################
|
||||||
|
|
|
@ -1,11 +1,7 @@
|
||||||
import base64
|
import base64
|
||||||
import uuid
|
import uuid
|
||||||
import os
|
import os
|
||||||
from openpyxl.chart import (
|
from openpyxl.chart import PieChart, LineChart, Reference
|
||||||
PieChart,
|
|
||||||
LineChart,
|
|
||||||
Reference,
|
|
||||||
)
|
|
||||||
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
||||||
from openpyxl.drawing.image import Image
|
from openpyxl.drawing.image import Image
|
||||||
from openpyxl import Workbook
|
from openpyxl import Workbook
|
||||||
|
|
|
@ -1,11 +1,7 @@
|
||||||
import base64
|
import base64
|
||||||
import uuid
|
import uuid
|
||||||
import os
|
import os
|
||||||
from openpyxl.chart import (
|
from openpyxl.chart import PieChart, LineChart, Reference
|
||||||
PieChart,
|
|
||||||
LineChart,
|
|
||||||
Reference,
|
|
||||||
)
|
|
||||||
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
||||||
from openpyxl.drawing.image import Image
|
from openpyxl.drawing.image import Image
|
||||||
from openpyxl import Workbook
|
from openpyxl import Workbook
|
||||||
|
|
|
@ -1,10 +1,7 @@
|
||||||
import base64
|
import base64
|
||||||
import uuid
|
import uuid
|
||||||
import os
|
import os
|
||||||
from openpyxl.chart import (
|
from openpyxl.chart import LineChart, Reference
|
||||||
LineChart,
|
|
||||||
Reference,
|
|
||||||
)
|
|
||||||
from openpyxl.chart.label import DataLabelList
|
from openpyxl.chart.label import DataLabelList
|
||||||
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
||||||
from openpyxl.drawing.image import Image
|
from openpyxl.drawing.image import Image
|
||||||
|
@ -161,98 +158,92 @@ def generate_excel(report,
|
||||||
####################################################################################################################
|
####################################################################################################################
|
||||||
reporting_period_data = report['reporting_period']
|
reporting_period_data = report['reporting_period']
|
||||||
|
|
||||||
has_energy_data_flag = True
|
|
||||||
|
|
||||||
if "names" not in reporting_period_data.keys() or \
|
if "names" not in reporting_period_data.keys() or \
|
||||||
reporting_period_data['names'] is None or \
|
reporting_period_data['names'] is None or \
|
||||||
len(reporting_period_data['names']) == 0:
|
len(reporting_period_data['names']) == 0:
|
||||||
has_energy_data_flag = False
|
|
||||||
|
|
||||||
filename = str(uuid.uuid4()) + '.xlsx'
|
filename = str(uuid.uuid4()) + '.xlsx'
|
||||||
wb.save(filename)
|
wb.save(filename)
|
||||||
|
|
||||||
return filename
|
return filename
|
||||||
|
|
||||||
if has_energy_data_flag:
|
ws['B6'].font = title_font
|
||||||
ws['B6'].font = title_font
|
ws['B6'] = name + ' 统计分析'
|
||||||
ws['B6'] = name + ' 统计分析'
|
|
||||||
|
|
||||||
category = reporting_period_data['names']
|
category = reporting_period_data['names']
|
||||||
|
|
||||||
# table_title
|
# table_title
|
||||||
ws['B7'].fill = table_fill
|
ws['B7'].fill = table_fill
|
||||||
ws['B7'].font = title_font
|
ws['B7'].font = title_font
|
||||||
ws['B7'].alignment = c_c_alignment
|
ws['B7'].alignment = c_c_alignment
|
||||||
ws['B7'] = '报告期'
|
ws['B7'] = '报告期'
|
||||||
ws['B7'].border = f_border
|
ws['B7'].border = f_border
|
||||||
|
|
||||||
ws['C7'].font = title_font
|
ws['C7'].font = title_font
|
||||||
ws['C7'].alignment = c_c_alignment
|
ws['C7'].alignment = c_c_alignment
|
||||||
ws['C7'] = '平均负荷'
|
ws['C7'] = '平均负荷'
|
||||||
ws['C7'].border = f_border
|
ws['C7'].border = f_border
|
||||||
|
|
||||||
ws['D7'].font = title_font
|
ws['D7'].font = title_font
|
||||||
ws['D7'].alignment = c_c_alignment
|
ws['D7'].alignment = c_c_alignment
|
||||||
ws['D7'] = '最大负荷'
|
ws['D7'] = '最大负荷'
|
||||||
ws['D7'].border = f_border
|
ws['D7'].border = f_border
|
||||||
|
|
||||||
ws['E7'].font = title_font
|
ws['E7'].font = title_font
|
||||||
ws['E7'].alignment = c_c_alignment
|
ws['E7'].alignment = c_c_alignment
|
||||||
ws['E7'] = '负荷系数'
|
ws['E7'] = '负荷系数'
|
||||||
ws['E7'].border = f_border
|
ws['E7'].border = f_border
|
||||||
|
|
||||||
# table_data
|
# table_data
|
||||||
|
|
||||||
for i, value in enumerate(category):
|
for i, value in enumerate(category):
|
||||||
row = i * 2 + 8
|
row = i * 2 + 8
|
||||||
ws['B' + str(row)].font = name_font
|
ws['B' + str(row)].font = name_font
|
||||||
ws['B' + str(row)].alignment = c_c_alignment
|
ws['B' + str(row)].alignment = c_c_alignment
|
||||||
ws['B' + str(row)] = reporting_period_data['names'][i] + " (" + reporting_period_data['units'][i] + "/H )"
|
ws['B' + str(row)] = reporting_period_data['names'][i] + " (" + reporting_period_data['units'][i] + "/H )"
|
||||||
ws['B' + str(row)].border = f_border
|
ws['B' + str(row)].border = f_border
|
||||||
|
|
||||||
ws['B' + str(row + 1)].font = name_font
|
ws['B' + str(row + 1)].font = name_font
|
||||||
ws['B' + str(row + 1)].alignment = c_c_alignment
|
ws['B' + str(row + 1)].alignment = c_c_alignment
|
||||||
ws['B' + str(row + 1)] = "环比"
|
ws['B' + str(row + 1)] = "环比"
|
||||||
ws['B' + str(row + 1)].border = f_border
|
ws['B' + str(row + 1)].border = f_border
|
||||||
|
|
||||||
ws['C' + str(row)].font = name_font
|
ws['C' + str(row)].font = name_font
|
||||||
ws['C' + str(row)].alignment = c_c_alignment
|
ws['C' + str(row)].alignment = c_c_alignment
|
||||||
ws['C' + str(row)] = round(reporting_period_data['averages'][i], 2) \
|
ws['C' + str(row)] = round(reporting_period_data['averages'][i], 2) \
|
||||||
if reporting_period_data['averages'][i] is not None else ''
|
if reporting_period_data['averages'][i] is not None else ''
|
||||||
ws['C' + str(row)].border = f_border
|
ws['C' + str(row)].border = f_border
|
||||||
ws['C' + str(row)].number_format = '0.00'
|
ws['C' + str(row)].number_format = '0.00'
|
||||||
|
|
||||||
ws['C' + str(row + 1)].font = name_font
|
ws['C' + str(row + 1)].font = name_font
|
||||||
ws['C' + str(row + 1)].alignment = c_c_alignment
|
ws['C' + str(row + 1)].alignment = c_c_alignment
|
||||||
ws['C' + str(row + 1)] = str(round(reporting_period_data['averages_increment_rate'][i] * 100, 2)) + "%" \
|
ws['C' + str(row + 1)] = str(round(reporting_period_data['averages_increment_rate'][i] * 100, 2)) + "%" \
|
||||||
if reporting_period_data['averages_increment_rate'][i] is not None else '0.00%'
|
if reporting_period_data['averages_increment_rate'][i] is not None else '0.00%'
|
||||||
ws['C' + str(row + 1)].border = f_border
|
ws['C' + str(row + 1)].border = f_border
|
||||||
|
|
||||||
ws['D' + str(row)].font = name_font
|
ws['D' + str(row)].font = name_font
|
||||||
ws['D' + str(row)].alignment = c_c_alignment
|
ws['D' + str(row)].alignment = c_c_alignment
|
||||||
ws['D' + str(row)] = round(reporting_period_data['maximums'][i], 2) \
|
ws['D' + str(row)] = round(reporting_period_data['maximums'][i], 2) \
|
||||||
if reporting_period_data['maximums'][i] is not None else ''
|
if reporting_period_data['maximums'][i] is not None else ''
|
||||||
ws['D' + str(row)].border = f_border
|
ws['D' + str(row)].border = f_border
|
||||||
ws['D' + str(row)].number_format = '0.00'
|
ws['D' + str(row)].number_format = '0.00'
|
||||||
|
|
||||||
ws['D' + str(row + 1)].font = name_font
|
ws['D' + str(row + 1)].font = name_font
|
||||||
ws['D' + str(row + 1)].alignment = c_c_alignment
|
ws['D' + str(row + 1)].alignment = c_c_alignment
|
||||||
ws['D' + str(row + 1)] = str(round(reporting_period_data['maximums_increment_rate'][i] * 100, 2)) + "%" \
|
ws['D' + str(row + 1)] = str(round(reporting_period_data['maximums_increment_rate'][i] * 100, 2)) + "%" \
|
||||||
if reporting_period_data['maximums_increment_rate'][i] is not None else '0.00%'
|
if reporting_period_data['maximums_increment_rate'][i] is not None else '0.00%'
|
||||||
ws['D' + str(row + 1)].border = f_border
|
ws['D' + str(row + 1)].border = f_border
|
||||||
|
|
||||||
ws['E' + str(row)].font = name_font
|
ws['E' + str(row)].font = name_font
|
||||||
ws['E' + str(row)].alignment = c_c_alignment
|
ws['E' + str(row)].alignment = c_c_alignment
|
||||||
ws['E' + str(row)] = round(reporting_period_data['factors'][i], 2) \
|
ws['E' + str(row)] = round(reporting_period_data['factors'][i], 2) \
|
||||||
if reporting_period_data['factors'][i] is not None else ''
|
if reporting_period_data['factors'][i] is not None else ''
|
||||||
ws['E' + str(row)].border = f_border
|
ws['E' + str(row)].border = f_border
|
||||||
ws['E' + str(row)].number_format = '0.00'
|
ws['E' + str(row)].number_format = '0.00'
|
||||||
|
|
||||||
ws['E' + str(row + 1)].font = name_font
|
ws['E' + str(row + 1)].font = name_font
|
||||||
ws['E' + str(row + 1)].alignment = c_c_alignment
|
ws['E' + str(row + 1)].alignment = c_c_alignment
|
||||||
ws['E' + str(row + 1)] = str(round(reporting_period_data['factors_increment_rate'][i] * 100, 2)) + "%" \
|
ws['E' + str(row + 1)] = str(round(reporting_period_data['factors_increment_rate'][i] * 100, 2)) + "%" \
|
||||||
if reporting_period_data['factors_increment_rate'][i] is not None else '0.00%'
|
if reporting_period_data['factors_increment_rate'][i] is not None else '0.00%'
|
||||||
ws['E' + str(row + 1)].border = f_border
|
ws['E' + str(row + 1)].border = f_border
|
||||||
|
|
||||||
####################################################################################################################
|
####################################################################################################################
|
||||||
# Second: 报告期单位面积消耗
|
# Second: 报告期单位面积消耗
|
||||||
|
@ -261,58 +252,57 @@ def generate_excel(report,
|
||||||
# per_unit_area_start_row_number + 2 ~ per_unit_area_start_row_number + 2 + ca_len : table_data
|
# per_unit_area_start_row_number + 2 ~ per_unit_area_start_row_number + 2 + ca_len : table_data
|
||||||
####################################################################################################################
|
####################################################################################################################
|
||||||
|
|
||||||
if has_energy_data_flag:
|
names = reporting_period_data['names']
|
||||||
names = reporting_period_data['names']
|
ca_len = len(names)
|
||||||
ca_len = len(names)
|
per_unit_area_start_row_number = 9 + ca_len * 2
|
||||||
per_unit_area_start_row_number = 9 + ca_len * 2
|
|
||||||
|
|
||||||
ws['B' + str(per_unit_area_start_row_number)].font = title_font
|
ws['B' + str(per_unit_area_start_row_number)].font = title_font
|
||||||
ws['B' + str(per_unit_area_start_row_number)] = name + ' 单位面积值' + str(report['store']['area']) + 'M²'
|
ws['B' + str(per_unit_area_start_row_number)] = name + ' 单位面积值' + str(report['store']['area']) + 'M²'
|
||||||
|
|
||||||
category = reporting_period_data['names']
|
category = reporting_period_data['names']
|
||||||
|
|
||||||
# table_title
|
# table_title
|
||||||
ws['B' + str(per_unit_area_start_row_number + 1)].fill = table_fill
|
ws['B' + str(per_unit_area_start_row_number + 1)].fill = table_fill
|
||||||
ws['B' + str(per_unit_area_start_row_number + 1)].font = title_font
|
ws['B' + str(per_unit_area_start_row_number + 1)].font = title_font
|
||||||
ws['B' + str(per_unit_area_start_row_number + 1)].alignment = c_c_alignment
|
ws['B' + str(per_unit_area_start_row_number + 1)].alignment = c_c_alignment
|
||||||
ws['B' + str(per_unit_area_start_row_number + 1)] = '报告期'
|
ws['B' + str(per_unit_area_start_row_number + 1)] = '报告期'
|
||||||
ws['B' + str(per_unit_area_start_row_number + 1)].border = f_border
|
ws['B' + str(per_unit_area_start_row_number + 1)].border = f_border
|
||||||
|
|
||||||
ws['C' + str(per_unit_area_start_row_number + 1)].font = title_font
|
ws['C' + str(per_unit_area_start_row_number + 1)].font = title_font
|
||||||
ws['C' + str(per_unit_area_start_row_number + 1)].alignment = c_c_alignment
|
ws['C' + str(per_unit_area_start_row_number + 1)].alignment = c_c_alignment
|
||||||
ws['C' + str(per_unit_area_start_row_number + 1)] = '平均负荷'
|
ws['C' + str(per_unit_area_start_row_number + 1)] = '平均负荷'
|
||||||
ws['C' + str(per_unit_area_start_row_number + 1)].border = f_border
|
ws['C' + str(per_unit_area_start_row_number + 1)].border = f_border
|
||||||
|
|
||||||
ws['D' + str(per_unit_area_start_row_number + 1)].font = title_font
|
ws['D' + str(per_unit_area_start_row_number + 1)].font = title_font
|
||||||
ws['D' + str(per_unit_area_start_row_number + 1)].alignment = c_c_alignment
|
ws['D' + str(per_unit_area_start_row_number + 1)].alignment = c_c_alignment
|
||||||
ws['D' + str(per_unit_area_start_row_number + 1)] = '最大负荷'
|
ws['D' + str(per_unit_area_start_row_number + 1)] = '最大负荷'
|
||||||
ws['D' + str(per_unit_area_start_row_number + 1)].border = f_border
|
ws['D' + str(per_unit_area_start_row_number + 1)].border = f_border
|
||||||
|
|
||||||
# table_data
|
# table_data
|
||||||
|
|
||||||
for i, value in enumerate(category):
|
for i, value in enumerate(category):
|
||||||
row_data = per_unit_area_start_row_number + 2 + i
|
row_data = per_unit_area_start_row_number + 2 + i
|
||||||
ws['B' + str(row_data)].font = name_font
|
ws['B' + str(row_data)].font = name_font
|
||||||
ws['B' + str(row_data)].alignment = c_c_alignment
|
ws['B' + str(row_data)].alignment = c_c_alignment
|
||||||
ws['B' + str(row_data)] = reporting_period_data['names'][i] + " (" + reporting_period_data['units'][
|
ws['B' + str(row_data)] = reporting_period_data['names'][i] + " (" + reporting_period_data['units'][
|
||||||
i] + "/H/M²)"
|
i] + "/H/M²)"
|
||||||
ws['B' + str(row_data)].border = f_border
|
ws['B' + str(row_data)].border = f_border
|
||||||
|
|
||||||
ws['C' + str(row_data)].font = name_font
|
ws['C' + str(row_data)].font = name_font
|
||||||
ws['C' + str(row_data)].alignment = c_c_alignment
|
ws['C' + str(row_data)].alignment = c_c_alignment
|
||||||
if reporting_period_data['averages_per_unit_area'][i] \
|
if reporting_period_data['averages_per_unit_area'][i] \
|
||||||
or reporting_period_data['averages_per_unit_area'][i] == 0:
|
or reporting_period_data['averages_per_unit_area'][i] == 0:
|
||||||
ws['C' + str(row_data)] = round(reporting_period_data['averages_per_unit_area'][i], 2)
|
ws['C' + str(row_data)] = round(reporting_period_data['averages_per_unit_area'][i], 2)
|
||||||
ws['C' + str(row_data)].border = f_border
|
ws['C' + str(row_data)].border = f_border
|
||||||
ws['C' + str(row_data)].number_format = '0.00'
|
ws['C' + str(row_data)].number_format = '0.00'
|
||||||
|
|
||||||
ws['D' + str(row_data)].font = name_font
|
ws['D' + str(row_data)].font = name_font
|
||||||
ws['D' + str(row_data)].alignment = c_c_alignment
|
ws['D' + str(row_data)].alignment = c_c_alignment
|
||||||
if reporting_period_data['maximums_per_unit_area'][i] \
|
if reporting_period_data['maximums_per_unit_area'][i] \
|
||||||
or reporting_period_data['maximums_per_unit_area'][i] == 0:
|
or reporting_period_data['maximums_per_unit_area'][i] == 0:
|
||||||
ws['D' + str(row_data)] = round(reporting_period_data['maximums_per_unit_area'][i], 2)
|
ws['D' + str(row_data)] = round(reporting_period_data['maximums_per_unit_area'][i], 2)
|
||||||
ws['D' + str(row_data)].border = f_border
|
ws['D' + str(row_data)].border = f_border
|
||||||
ws['D' + str(row_data)].number_format = '0.00'
|
ws['D' + str(row_data)].number_format = '0.00'
|
||||||
|
|
||||||
####################################################################################################################
|
####################################################################################################################
|
||||||
# Third: 详细数据
|
# Third: 详细数据
|
||||||
|
|
|
@ -1,11 +1,8 @@
|
||||||
import base64
|
import base64
|
||||||
import uuid
|
import uuid
|
||||||
import os
|
import os
|
||||||
from openpyxl.chart import (
|
from decimal import Decimal
|
||||||
PieChart,
|
from openpyxl.chart import PieChart, LineChart, Reference
|
||||||
LineChart,
|
|
||||||
Reference,
|
|
||||||
)
|
|
||||||
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
||||||
from openpyxl.drawing.image import Image
|
from openpyxl.drawing.image import Image
|
||||||
from openpyxl import Workbook
|
from openpyxl import Workbook
|
||||||
|
@ -781,11 +778,9 @@ def generate_excel(report,
|
||||||
|
|
||||||
|
|
||||||
def sum_list(lists):
|
def sum_list(lists):
|
||||||
total = 0
|
total = Decimal(0)
|
||||||
|
|
||||||
for i in range(0, len(lists)):
|
for i in range(0, len(lists)):
|
||||||
total += lists[i]
|
total += lists[i]
|
||||||
|
|
||||||
return total
|
return total
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,8 @@
|
||||||
import base64
|
import base64
|
||||||
import os
|
import os
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from openpyxl import Workbook
|
from openpyxl import Workbook
|
||||||
from openpyxl.chart import (
|
from openpyxl.chart import LineChart, Reference
|
||||||
LineChart,
|
|
||||||
Reference,
|
|
||||||
)
|
|
||||||
from openpyxl.chart.label import DataLabelList
|
from openpyxl.chart.label import DataLabelList
|
||||||
from openpyxl.drawing.image import Image
|
from openpyxl.drawing.image import Image
|
||||||
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
||||||
|
@ -160,152 +156,146 @@ def generate_excel(report,
|
||||||
####################################################################################################################
|
####################################################################################################################
|
||||||
reporting_period_data = report['reporting_period']
|
reporting_period_data = report['reporting_period']
|
||||||
|
|
||||||
has_energy_data_flag = True
|
|
||||||
|
|
||||||
if "names" not in reporting_period_data.keys() or \
|
if "names" not in reporting_period_data.keys() or \
|
||||||
reporting_period_data['names'] is None or \
|
reporting_period_data['names'] is None or \
|
||||||
len(reporting_period_data['names']) == 0:
|
len(reporting_period_data['names']) == 0:
|
||||||
has_energy_data_flag = False
|
|
||||||
|
|
||||||
filename = str(uuid.uuid4()) + '.xlsx'
|
filename = str(uuid.uuid4()) + '.xlsx'
|
||||||
wb.save(filename)
|
wb.save(filename)
|
||||||
|
|
||||||
return filename
|
return filename
|
||||||
|
|
||||||
if has_energy_data_flag:
|
ws['B6'].font = title_font
|
||||||
ws['B6'].font = title_font
|
ws['B6'] = name + ' 统计分析'
|
||||||
ws['B6'] = name + ' 统计分析'
|
|
||||||
|
|
||||||
category = reporting_period_data['names']
|
category = reporting_period_data['names']
|
||||||
|
|
||||||
# table_title
|
# table_title
|
||||||
ws['B7'].fill = table_fill
|
ws['B7'].fill = table_fill
|
||||||
ws['B7'].font = title_font
|
ws['B7'].font = title_font
|
||||||
ws['B7'].alignment = c_c_alignment
|
ws['B7'].alignment = c_c_alignment
|
||||||
ws['B7'] = '报告期'
|
ws['B7'] = '报告期'
|
||||||
ws['B7'].border = f_border
|
ws['B7'].border = f_border
|
||||||
|
|
||||||
ws['C7'].font = title_font
|
ws['C7'].font = title_font
|
||||||
ws['C7'].alignment = c_c_alignment
|
ws['C7'].alignment = c_c_alignment
|
||||||
ws['C7'] = '算术平均数'
|
ws['C7'] = '算术平均数'
|
||||||
ws['C7'].border = f_border
|
ws['C7'].border = f_border
|
||||||
|
|
||||||
ws['D7'].font = title_font
|
ws['D7'].font = title_font
|
||||||
ws['D7'].alignment = c_c_alignment
|
ws['D7'].alignment = c_c_alignment
|
||||||
ws['D7'] = '中位数'
|
ws['D7'] = '中位数'
|
||||||
ws['D7'].border = f_border
|
ws['D7'].border = f_border
|
||||||
|
|
||||||
ws['E7'].font = title_font
|
ws['E7'].font = title_font
|
||||||
ws['E7'].alignment = c_c_alignment
|
ws['E7'].alignment = c_c_alignment
|
||||||
ws['E7'] = '最小值'
|
ws['E7'] = '最小值'
|
||||||
ws['E7'].border = f_border
|
ws['E7'].border = f_border
|
||||||
|
|
||||||
ws['F7'].font = title_font
|
ws['F7'].font = title_font
|
||||||
ws['F7'].alignment = c_c_alignment
|
ws['F7'].alignment = c_c_alignment
|
||||||
ws['F7'] = '最大值'
|
ws['F7'] = '最大值'
|
||||||
ws['F7'].border = f_border
|
ws['F7'].border = f_border
|
||||||
|
|
||||||
ws['G7'].font = title_font
|
ws['G7'].font = title_font
|
||||||
ws['G7'].alignment = c_c_alignment
|
ws['G7'].alignment = c_c_alignment
|
||||||
ws['G7'] = '样本标准差'
|
ws['G7'] = '样本标准差'
|
||||||
ws['G7'].border = f_border
|
ws['G7'].border = f_border
|
||||||
|
|
||||||
ws['H7'].font = title_font
|
ws['H7'].font = title_font
|
||||||
ws['H7'].alignment = c_c_alignment
|
ws['H7'].alignment = c_c_alignment
|
||||||
ws['H7'] = '样本方差'
|
ws['H7'] = '样本方差'
|
||||||
ws['H7'].border = f_border
|
ws['H7'].border = f_border
|
||||||
|
|
||||||
# table_data
|
# table_data
|
||||||
|
|
||||||
for i, value in enumerate(category):
|
for i, value in enumerate(category):
|
||||||
row = i * 2 + 8
|
row = i * 2 + 8
|
||||||
ws['B' + str(row)].font = name_font
|
ws['B' + str(row)].font = name_font
|
||||||
ws['B' + str(row)].alignment = c_c_alignment
|
ws['B' + str(row)].alignment = c_c_alignment
|
||||||
ws['B' + str(row)] = reporting_period_data['names'][i] + " (" + reporting_period_data['units'][i] + " )"
|
ws['B' + str(row)] = reporting_period_data['names'][i] + " (" + reporting_period_data['units'][i] + " )"
|
||||||
ws['B' + str(row)].border = f_border
|
ws['B' + str(row)].border = f_border
|
||||||
|
|
||||||
ws['B' + str(row + 1)].font = name_font
|
ws['B' + str(row + 1)].font = name_font
|
||||||
ws['B' + str(row + 1)].alignment = c_c_alignment
|
ws['B' + str(row + 1)].alignment = c_c_alignment
|
||||||
ws['B' + str(row + 1)] = "环比"
|
ws['B' + str(row + 1)] = "环比"
|
||||||
ws['B' + str(row + 1)].border = f_border
|
ws['B' + str(row + 1)].border = f_border
|
||||||
|
|
||||||
ws['C' + str(row)].font = name_font
|
ws['C' + str(row)].font = name_font
|
||||||
ws['C' + str(row)].alignment = c_c_alignment
|
ws['C' + str(row)].alignment = c_c_alignment
|
||||||
ws['C' + str(row)] = round(reporting_period_data['means'][i], 2) \
|
ws['C' + str(row)] = round(reporting_period_data['means'][i], 2) \
|
||||||
if reporting_period_data['means'][i] is not None else ''
|
if reporting_period_data['means'][i] is not None else ''
|
||||||
ws['C' + str(row)].border = f_border
|
ws['C' + str(row)].border = f_border
|
||||||
ws['C' + str(row)].number_format = '0.00'
|
ws['C' + str(row)].number_format = '0.00'
|
||||||
|
|
||||||
ws['C' + str(row + 1)].font = name_font
|
ws['C' + str(row + 1)].font = name_font
|
||||||
ws['C' + str(row + 1)].alignment = c_c_alignment
|
ws['C' + str(row + 1)].alignment = c_c_alignment
|
||||||
ws['C' + str(row + 1)] = str(round(reporting_period_data['means_increment_rate'][i] * 100, 2)) + "%" \
|
ws['C' + str(row + 1)] = str(round(reporting_period_data['means_increment_rate'][i] * 100, 2)) + "%" \
|
||||||
if reporting_period_data['means_increment_rate'][i] is not None else '0.00%'
|
if reporting_period_data['means_increment_rate'][i] is not None else '0.00%'
|
||||||
ws['C' + str(row + 1)].border = f_border
|
ws['C' + str(row + 1)].border = f_border
|
||||||
|
|
||||||
ws['D' + str(row)].font = name_font
|
ws['D' + str(row)].font = name_font
|
||||||
ws['D' + str(row)].alignment = c_c_alignment
|
ws['D' + str(row)].alignment = c_c_alignment
|
||||||
ws['D' + str(row)] = round(reporting_period_data['medians'][i], 2) \
|
ws['D' + str(row)] = round(reporting_period_data['medians'][i], 2) \
|
||||||
if reporting_period_data['medians'][i] is not None else ''
|
if reporting_period_data['medians'][i] is not None else ''
|
||||||
ws['D' + str(row)].border = f_border
|
ws['D' + str(row)].border = f_border
|
||||||
ws['D' + str(row)].number_format = '0.00'
|
ws['D' + str(row)].number_format = '0.00'
|
||||||
|
|
||||||
ws['D' + str(row + 1)].font = name_font
|
ws['D' + str(row + 1)].font = name_font
|
||||||
ws['D' + str(row + 1)].alignment = c_c_alignment
|
ws['D' + str(row + 1)].alignment = c_c_alignment
|
||||||
ws['D' + str(row + 1)] = str(round(reporting_period_data['medians_increment_rate'][i] * 100, 2)) + "%" \
|
ws['D' + str(row + 1)] = str(round(reporting_period_data['medians_increment_rate'][i] * 100, 2)) + "%" \
|
||||||
if reporting_period_data['medians_increment_rate'][i] is not None else '0.00%'
|
if reporting_period_data['medians_increment_rate'][i] is not None else '0.00%'
|
||||||
ws['D' + str(row + 1)].border = f_border
|
ws['D' + str(row + 1)].border = f_border
|
||||||
|
|
||||||
ws['E' + str(row)].font = name_font
|
ws['E' + str(row)].font = name_font
|
||||||
ws['E' + str(row)].alignment = c_c_alignment
|
ws['E' + str(row)].alignment = c_c_alignment
|
||||||
ws['E' + str(row)] = round(reporting_period_data['minimums'][i], 2) \
|
ws['E' + str(row)] = round(reporting_period_data['minimums'][i], 2) \
|
||||||
if reporting_period_data['minimums'][i] is not None else ''
|
if reporting_period_data['minimums'][i] is not None else ''
|
||||||
ws['E' + str(row)].border = f_border
|
ws['E' + str(row)].border = f_border
|
||||||
ws['E' + str(row)].number_format = '0.00'
|
ws['E' + str(row)].number_format = '0.00'
|
||||||
|
|
||||||
ws['E' + str(row + 1)].font = name_font
|
ws['E' + str(row + 1)].font = name_font
|
||||||
ws['E' + str(row + 1)].alignment = c_c_alignment
|
ws['E' + str(row + 1)].alignment = c_c_alignment
|
||||||
ws['E' + str(row + 1)] = str(round(reporting_period_data['minimums_increment_rate'][i] * 100, 2)) + "%" \
|
ws['E' + str(row + 1)] = str(round(reporting_period_data['minimums_increment_rate'][i] * 100, 2)) + "%" \
|
||||||
if reporting_period_data['minimums_increment_rate'][i] is not None else '0.00%'
|
if reporting_period_data['minimums_increment_rate'][i] is not None else '0.00%'
|
||||||
ws['E' + str(row + 1)].border = f_border
|
ws['E' + str(row + 1)].border = f_border
|
||||||
|
|
||||||
ws['F' + str(row)].font = name_font
|
ws['F' + str(row)].font = name_font
|
||||||
ws['F' + str(row)].alignment = c_c_alignment
|
ws['F' + str(row)].alignment = c_c_alignment
|
||||||
ws['F' + str(row)] = round(reporting_period_data['maximums'][i], 2) \
|
ws['F' + str(row)] = round(reporting_period_data['maximums'][i], 2) \
|
||||||
if reporting_period_data['maximums'][i] is not None else ''
|
if reporting_period_data['maximums'][i] is not None else ''
|
||||||
ws['F' + str(row)].border = f_border
|
ws['F' + str(row)].border = f_border
|
||||||
ws['F' + str(row)].number_format = '0.00'
|
ws['F' + str(row)].number_format = '0.00'
|
||||||
|
|
||||||
ws['F' + str(row + 1)].font = name_font
|
ws['F' + str(row + 1)].font = name_font
|
||||||
ws['F' + str(row + 1)].alignment = c_c_alignment
|
ws['F' + str(row + 1)].alignment = c_c_alignment
|
||||||
ws['F' + str(row + 1)] = str(round(reporting_period_data['maximums_increment_rate'][i] * 100, 2)) + "%" \
|
ws['F' + str(row + 1)] = str(round(reporting_period_data['maximums_increment_rate'][i] * 100, 2)) + "%" \
|
||||||
if reporting_period_data['maximums_increment_rate'][i] is not None else '0.00%'
|
if reporting_period_data['maximums_increment_rate'][i] is not None else '0.00%'
|
||||||
ws['F' + str(row + 1)].border = f_border
|
ws['F' + str(row + 1)].border = f_border
|
||||||
|
|
||||||
ws['G' + str(row)].font = name_font
|
ws['G' + str(row)].font = name_font
|
||||||
ws['G' + str(row)].alignment = c_c_alignment
|
ws['G' + str(row)].alignment = c_c_alignment
|
||||||
ws['G' + str(row)] = round(reporting_period_data['stdevs'][i], 2) \
|
ws['G' + str(row)] = round(reporting_period_data['stdevs'][i], 2) \
|
||||||
if reporting_period_data['stdevs'][i] is not None else ''
|
if reporting_period_data['stdevs'][i] is not None else ''
|
||||||
ws['G' + str(row)].border = f_border
|
ws['G' + str(row)].border = f_border
|
||||||
ws['G' + str(row)].number_format = '0.00'
|
ws['G' + str(row)].number_format = '0.00'
|
||||||
|
|
||||||
ws['G' + str(row + 1)].font = name_font
|
ws['G' + str(row + 1)].font = name_font
|
||||||
ws['G' + str(row + 1)].alignment = c_c_alignment
|
ws['G' + str(row + 1)].alignment = c_c_alignment
|
||||||
ws['G' + str(row + 1)] = str(round(reporting_period_data['stdevs_increment_rate'][i] * 100, 2)) + "%" \
|
ws['G' + str(row + 1)] = str(round(reporting_period_data['stdevs_increment_rate'][i] * 100, 2)) + "%" \
|
||||||
if reporting_period_data['stdevs_increment_rate'][i] is not None else '0.00%'
|
if reporting_period_data['stdevs_increment_rate'][i] is not None else '0.00%'
|
||||||
ws['G' + str(row + 1)].border = f_border
|
ws['G' + str(row + 1)].border = f_border
|
||||||
|
|
||||||
ws['H' + str(row)].font = name_font
|
ws['H' + str(row)].font = name_font
|
||||||
ws['H' + str(row)].alignment = c_c_alignment
|
ws['H' + str(row)].alignment = c_c_alignment
|
||||||
ws['H' + str(row)] = round(reporting_period_data['variances'][i], 2) \
|
ws['H' + str(row)] = round(reporting_period_data['variances'][i], 2) \
|
||||||
if reporting_period_data['variances'][i] is not None else ''
|
if reporting_period_data['variances'][i] is not None else ''
|
||||||
ws['H' + str(row)].border = f_border
|
ws['H' + str(row)].border = f_border
|
||||||
ws['H' + str(row)].number_format = '0.00'
|
ws['H' + str(row)].number_format = '0.00'
|
||||||
|
|
||||||
ws['H' + str(row + 1)].font = name_font
|
ws['H' + str(row + 1)].font = name_font
|
||||||
ws['H' + str(row + 1)].alignment = c_c_alignment
|
ws['H' + str(row + 1)].alignment = c_c_alignment
|
||||||
ws['H' + str(row + 1)] = str(round(reporting_period_data['variances_increment_rate'][i] * 100, 2)) + "%" \
|
ws['H' + str(row + 1)] = str(round(reporting_period_data['variances_increment_rate'][i] * 100, 2)) + "%" \
|
||||||
if reporting_period_data['variances_increment_rate'][i] is not None else '0.00%'
|
if reporting_period_data['variances_increment_rate'][i] is not None else '0.00%'
|
||||||
ws['H' + str(row + 1)].border = f_border
|
ws['H' + str(row + 1)].border = f_border
|
||||||
####################################################################################################################
|
####################################################################################################################
|
||||||
# Second: 报告期消耗
|
# Second: 报告期消耗
|
||||||
# 9 + ca_len * 2: title
|
# 9 + ca_len * 2: title
|
||||||
|
@ -313,111 +303,110 @@ def generate_excel(report,
|
||||||
# per_unit_area_start_row_number + 2 ~ per_unit_area_start_row_number + 2 + ca_len : table_data
|
# per_unit_area_start_row_number + 2 ~ per_unit_area_start_row_number + 2 + ca_len : table_data
|
||||||
####################################################################################################################
|
####################################################################################################################
|
||||||
|
|
||||||
if has_energy_data_flag:
|
names = reporting_period_data['names']
|
||||||
names = reporting_period_data['names']
|
ca_len = len(names)
|
||||||
ca_len = len(names)
|
|
||||||
|
|
||||||
per_unit_area_start_row_number = 9 + ca_len * 2
|
per_unit_area_start_row_number = 9 + ca_len * 2
|
||||||
|
|
||||||
ws['B' + str(per_unit_area_start_row_number)].font = title_font
|
ws['B' + str(per_unit_area_start_row_number)].font = title_font
|
||||||
ws['B' + str(per_unit_area_start_row_number)] = name + ' 单位面积值' + str(report['store']['area']) + 'M²'
|
ws['B' + str(per_unit_area_start_row_number)] = name + ' 单位面积值' + str(report['store']['area']) + 'M²'
|
||||||
|
|
||||||
category = reporting_period_data['names']
|
category = reporting_period_data['names']
|
||||||
|
|
||||||
# table_title
|
# table_title
|
||||||
ws['B' + str(per_unit_area_start_row_number + 1)].fill = table_fill
|
ws['B' + str(per_unit_area_start_row_number + 1)].fill = table_fill
|
||||||
ws['B' + str(per_unit_area_start_row_number + 1)].font = title_font
|
ws['B' + str(per_unit_area_start_row_number + 1)].font = title_font
|
||||||
ws['B' + str(per_unit_area_start_row_number + 1)].alignment = c_c_alignment
|
ws['B' + str(per_unit_area_start_row_number + 1)].alignment = c_c_alignment
|
||||||
ws['B' + str(per_unit_area_start_row_number + 1)] = '报告期'
|
ws['B' + str(per_unit_area_start_row_number + 1)] = '报告期'
|
||||||
ws['B' + str(per_unit_area_start_row_number + 1)].border = f_border
|
ws['B' + str(per_unit_area_start_row_number + 1)].border = f_border
|
||||||
|
|
||||||
ws['C' + str(per_unit_area_start_row_number + 1)].font = title_font
|
ws['C' + str(per_unit_area_start_row_number + 1)].font = title_font
|
||||||
ws['C' + str(per_unit_area_start_row_number + 1)].alignment = c_c_alignment
|
ws['C' + str(per_unit_area_start_row_number + 1)].alignment = c_c_alignment
|
||||||
ws['C' + str(per_unit_area_start_row_number + 1)] = '算术平均数'
|
ws['C' + str(per_unit_area_start_row_number + 1)] = '算术平均数'
|
||||||
ws['C' + str(per_unit_area_start_row_number + 1)].border = f_border
|
ws['C' + str(per_unit_area_start_row_number + 1)].border = f_border
|
||||||
|
|
||||||
ws['D' + str(per_unit_area_start_row_number + 1)].font = title_font
|
ws['D' + str(per_unit_area_start_row_number + 1)].font = title_font
|
||||||
ws['D' + str(per_unit_area_start_row_number + 1)].alignment = c_c_alignment
|
ws['D' + str(per_unit_area_start_row_number + 1)].alignment = c_c_alignment
|
||||||
ws['D' + str(per_unit_area_start_row_number + 1)] = '中位数'
|
ws['D' + str(per_unit_area_start_row_number + 1)] = '中位数'
|
||||||
ws['D' + str(per_unit_area_start_row_number + 1)].border = f_border
|
ws['D' + str(per_unit_area_start_row_number + 1)].border = f_border
|
||||||
|
|
||||||
ws['E' + str(per_unit_area_start_row_number + 1)].font = title_font
|
ws['E' + str(per_unit_area_start_row_number + 1)].font = title_font
|
||||||
ws['E' + str(per_unit_area_start_row_number + 1)].alignment = c_c_alignment
|
ws['E' + str(per_unit_area_start_row_number + 1)].alignment = c_c_alignment
|
||||||
ws['E' + str(per_unit_area_start_row_number + 1)] = '最小值'
|
ws['E' + str(per_unit_area_start_row_number + 1)] = '最小值'
|
||||||
ws['E' + str(per_unit_area_start_row_number + 1)].border = f_border
|
ws['E' + str(per_unit_area_start_row_number + 1)].border = f_border
|
||||||
|
|
||||||
ws['F' + str(per_unit_area_start_row_number + 1)].font = title_font
|
ws['F' + str(per_unit_area_start_row_number + 1)].font = title_font
|
||||||
ws['F' + str(per_unit_area_start_row_number + 1)].alignment = c_c_alignment
|
ws['F' + str(per_unit_area_start_row_number + 1)].alignment = c_c_alignment
|
||||||
ws['F' + str(per_unit_area_start_row_number + 1)] = '最大值'
|
ws['F' + str(per_unit_area_start_row_number + 1)] = '最大值'
|
||||||
ws['F' + str(per_unit_area_start_row_number + 1)].border = f_border
|
ws['F' + str(per_unit_area_start_row_number + 1)].border = f_border
|
||||||
|
|
||||||
ws['G' + str(per_unit_area_start_row_number + 1)].font = title_font
|
ws['G' + str(per_unit_area_start_row_number + 1)].font = title_font
|
||||||
ws['G' + str(per_unit_area_start_row_number + 1)].alignment = c_c_alignment
|
ws['G' + str(per_unit_area_start_row_number + 1)].alignment = c_c_alignment
|
||||||
ws['G' + str(per_unit_area_start_row_number + 1)] = '样本标准差'
|
ws['G' + str(per_unit_area_start_row_number + 1)] = '样本标准差'
|
||||||
ws['G' + str(per_unit_area_start_row_number + 1)].border = f_border
|
ws['G' + str(per_unit_area_start_row_number + 1)].border = f_border
|
||||||
|
|
||||||
ws['H' + str(per_unit_area_start_row_number + 1)].font = title_font
|
ws['H' + str(per_unit_area_start_row_number + 1)].font = title_font
|
||||||
ws['H' + str(per_unit_area_start_row_number + 1)].alignment = c_c_alignment
|
ws['H' + str(per_unit_area_start_row_number + 1)].alignment = c_c_alignment
|
||||||
ws['H' + str(per_unit_area_start_row_number + 1)] = '样本方差'
|
ws['H' + str(per_unit_area_start_row_number + 1)] = '样本方差'
|
||||||
ws['H' + str(per_unit_area_start_row_number + 1)].border = f_border
|
ws['H' + str(per_unit_area_start_row_number + 1)].border = f_border
|
||||||
|
|
||||||
# table_data
|
# table_data
|
||||||
|
|
||||||
for i, value in enumerate(category):
|
for i, value in enumerate(category):
|
||||||
row_data = per_unit_area_start_row_number + 2 + i
|
row_data = per_unit_area_start_row_number + 2 + i
|
||||||
ws['B' + str(row_data)].font = name_font
|
ws['B' + str(row_data)].font = name_font
|
||||||
ws['B' + str(row_data)].alignment = c_c_alignment
|
ws['B' + str(row_data)].alignment = c_c_alignment
|
||||||
ws['B' + str(row_data)] = reporting_period_data['names'][i] + " (" + reporting_period_data['units'][
|
ws['B' + str(row_data)] = reporting_period_data['names'][i] + " (" + reporting_period_data['units'][
|
||||||
i] + "/M²)"
|
i] + "/M²)"
|
||||||
ws['B' + str(row_data)].border = f_border
|
ws['B' + str(row_data)].border = f_border
|
||||||
|
|
||||||
ws['C' + str(row_data)].font = name_font
|
ws['C' + str(row_data)].font = name_font
|
||||||
ws['C' + str(row_data)].alignment = c_c_alignment
|
ws['C' + str(row_data)].alignment = c_c_alignment
|
||||||
if reporting_period_data['means_per_unit_area'][i] \
|
if reporting_period_data['means_per_unit_area'][i] \
|
||||||
or reporting_period_data['means_per_unit_area'][i] == 0:
|
or reporting_period_data['means_per_unit_area'][i] == 0:
|
||||||
ws['C' + str(row_data)] = round(reporting_period_data['means_per_unit_area'][i], 2)
|
ws['C' + str(row_data)] = round(reporting_period_data['means_per_unit_area'][i], 2)
|
||||||
ws['C' + str(row_data)].border = f_border
|
ws['C' + str(row_data)].border = f_border
|
||||||
ws['C' + str(row_data)].number_format = '0.00'
|
ws['C' + str(row_data)].number_format = '0.00'
|
||||||
|
|
||||||
ws['D' + str(row_data)].font = name_font
|
ws['D' + str(row_data)].font = name_font
|
||||||
ws['D' + str(row_data)].alignment = c_c_alignment
|
ws['D' + str(row_data)].alignment = c_c_alignment
|
||||||
if reporting_period_data['medians_per_unit_area'][i] \
|
if reporting_period_data['medians_per_unit_area'][i] \
|
||||||
or reporting_period_data['medians_per_unit_area'][i] == 0:
|
or reporting_period_data['medians_per_unit_area'][i] == 0:
|
||||||
ws['D' + str(row_data)] = round(reporting_period_data['medians_per_unit_area'][i], 2)
|
ws['D' + str(row_data)] = round(reporting_period_data['medians_per_unit_area'][i], 2)
|
||||||
ws['D' + str(row_data)].border = f_border
|
ws['D' + str(row_data)].border = f_border
|
||||||
ws['D' + str(row_data)].number_format = '0.00'
|
ws['D' + str(row_data)].number_format = '0.00'
|
||||||
|
|
||||||
ws['E' + str(row_data)].font = name_font
|
ws['E' + str(row_data)].font = name_font
|
||||||
ws['E' + str(row_data)].alignment = c_c_alignment
|
ws['E' + str(row_data)].alignment = c_c_alignment
|
||||||
if reporting_period_data['minimums_per_unit_area'][i] \
|
if reporting_period_data['minimums_per_unit_area'][i] \
|
||||||
or reporting_period_data['minimums_per_unit_area'][i] == 0:
|
or reporting_period_data['minimums_per_unit_area'][i] == 0:
|
||||||
ws['E' + str(row_data)] = round(reporting_period_data['minimums_per_unit_area'][i], 2)
|
ws['E' + str(row_data)] = round(reporting_period_data['minimums_per_unit_area'][i], 2)
|
||||||
ws['E' + str(row_data)].border = f_border
|
ws['E' + str(row_data)].border = f_border
|
||||||
ws['E' + str(row_data)].number_format = '0.00'
|
ws['E' + str(row_data)].number_format = '0.00'
|
||||||
|
|
||||||
ws['F' + str(row_data)].font = name_font
|
ws['F' + str(row_data)].font = name_font
|
||||||
ws['F' + str(row_data)].alignment = c_c_alignment
|
ws['F' + str(row_data)].alignment = c_c_alignment
|
||||||
if reporting_period_data['maximums_per_unit_area'][i] \
|
if reporting_period_data['maximums_per_unit_area'][i] \
|
||||||
or reporting_period_data['maximums_per_unit_area'][i] == 0:
|
or reporting_period_data['maximums_per_unit_area'][i] == 0:
|
||||||
ws['F' + str(row_data)] = round(reporting_period_data['maximums_per_unit_area'][i], 2)
|
ws['F' + str(row_data)] = round(reporting_period_data['maximums_per_unit_area'][i], 2)
|
||||||
ws['F' + str(row_data)].border = f_border
|
ws['F' + str(row_data)].border = f_border
|
||||||
ws['F' + str(row_data)].number_format = '0.00'
|
ws['F' + str(row_data)].number_format = '0.00'
|
||||||
|
|
||||||
ws['G' + str(row_data)].font = name_font
|
ws['G' + str(row_data)].font = name_font
|
||||||
ws['G' + str(row_data)].alignment = c_c_alignment
|
ws['G' + str(row_data)].alignment = c_c_alignment
|
||||||
if (reporting_period_data['stdevs_per_unit_area'][i]) \
|
if (reporting_period_data['stdevs_per_unit_area'][i]) \
|
||||||
or reporting_period_data['stdevs_per_unit_area'][i] == 0:
|
or reporting_period_data['stdevs_per_unit_area'][i] == 0:
|
||||||
ws['G' + str(row_data)] = round(reporting_period_data['stdevs_per_unit_area'][i], 2)
|
ws['G' + str(row_data)] = round(reporting_period_data['stdevs_per_unit_area'][i], 2)
|
||||||
ws['G' + str(row_data)].border = f_border
|
ws['G' + str(row_data)].border = f_border
|
||||||
ws['G' + str(row_data)].number_format = '0.00'
|
ws['G' + str(row_data)].number_format = '0.00'
|
||||||
|
|
||||||
ws['H' + str(row_data)].font = name_font
|
ws['H' + str(row_data)].font = name_font
|
||||||
ws['H' + str(row_data)].alignment = c_c_alignment
|
ws['H' + str(row_data)].alignment = c_c_alignment
|
||||||
if reporting_period_data['variances_per_unit_area'][i] \
|
if reporting_period_data['variances_per_unit_area'][i] \
|
||||||
or reporting_period_data['variances_per_unit_area'][i] == 0:
|
or reporting_period_data['variances_per_unit_area'][i] == 0:
|
||||||
ws['H' + str(row_data)] = round(reporting_period_data['variances_per_unit_area'][i], 2)
|
ws['H' + str(row_data)] = round(reporting_period_data['variances_per_unit_area'][i], 2)
|
||||||
ws['H' + str(row_data)].border = f_border
|
ws['H' + str(row_data)].border = f_border
|
||||||
ws['H' + str(row_data)].number_format = '0.00'
|
ws['H' + str(row_data)].number_format = '0.00'
|
||||||
|
|
||||||
####################################################################################################################
|
####################################################################################################################
|
||||||
# Third: 详细数据
|
# Third: 详细数据
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import base64
|
import base64
|
||||||
import uuid
|
import uuid
|
||||||
import os
|
import os
|
||||||
from openpyxl.styles import PatternFill, Border, Side, Alignment, Protection, Font
|
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
||||||
from openpyxl.drawing.image import Image
|
from openpyxl.drawing.image import Image
|
||||||
from openpyxl import Workbook
|
from openpyxl import Workbook
|
||||||
|
|
||||||
|
|
|
@ -2,16 +2,10 @@ import base64
|
||||||
import uuid
|
import uuid
|
||||||
import os
|
import os
|
||||||
import datetime
|
import datetime
|
||||||
from openpyxl.chart import (
|
|
||||||
PieChart,
|
|
||||||
BarChart,
|
|
||||||
Reference,
|
|
||||||
)
|
|
||||||
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
from openpyxl.drawing.image import Image
|
from openpyxl.drawing.image import Image
|
||||||
from openpyxl import Workbook
|
from openpyxl import Workbook
|
||||||
from openpyxl.chart.label import DataLabelList
|
|
||||||
|
|
||||||
|
|
||||||
########################################################################################################################
|
########################################################################################################################
|
||||||
|
@ -115,9 +109,6 @@ def generate_excel(report,
|
||||||
bottom=Side(border_style='medium', color='00000000'),
|
bottom=Side(border_style='medium', color='00000000'),
|
||||||
top=Side(border_style='medium', color='00000000')
|
top=Side(border_style='medium', color='00000000')
|
||||||
)
|
)
|
||||||
b_border = Border(
|
|
||||||
bottom=Side(border_style='medium', color='00000000'),
|
|
||||||
)
|
|
||||||
|
|
||||||
c_c_alignment = Alignment(vertical='center',
|
c_c_alignment = Alignment(vertical='center',
|
||||||
horizontal='center',
|
horizontal='center',
|
||||||
|
|
|
@ -1,12 +1,7 @@
|
||||||
import base64
|
import base64
|
||||||
import uuid
|
import uuid
|
||||||
import os
|
import os
|
||||||
from openpyxl.chart import (
|
from openpyxl.chart import PieChart, LineChart, Reference
|
||||||
PieChart,
|
|
||||||
LineChart,
|
|
||||||
BarChart,
|
|
||||||
Reference,
|
|
||||||
)
|
|
||||||
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
||||||
from openpyxl.drawing.image import Image
|
from openpyxl.drawing.image import Image
|
||||||
from openpyxl import Workbook
|
from openpyxl import Workbook
|
||||||
|
|
|
@ -1,12 +1,7 @@
|
||||||
import base64
|
import base64
|
||||||
import uuid
|
import uuid
|
||||||
import os
|
import os
|
||||||
from openpyxl.chart import (
|
from openpyxl.chart import PieChart, LineChart, Reference
|
||||||
PieChart,
|
|
||||||
LineChart,
|
|
||||||
BarChart,
|
|
||||||
Reference,
|
|
||||||
)
|
|
||||||
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
||||||
from openpyxl.drawing.image import Image
|
from openpyxl.drawing.image import Image
|
||||||
from openpyxl import Workbook
|
from openpyxl import Workbook
|
||||||
|
|
|
@ -1,12 +1,7 @@
|
||||||
import base64
|
import base64
|
||||||
import uuid
|
import uuid
|
||||||
import os
|
import os
|
||||||
from openpyxl.chart import (
|
from openpyxl.chart import PieChart, LineChart, Reference
|
||||||
PieChart,
|
|
||||||
LineChart,
|
|
||||||
BarChart,
|
|
||||||
Reference,
|
|
||||||
)
|
|
||||||
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
||||||
from openpyxl.drawing.image import Image
|
from openpyxl.drawing.image import Image
|
||||||
from openpyxl import Workbook
|
from openpyxl import Workbook
|
||||||
|
|
|
@ -1,12 +1,7 @@
|
||||||
import base64
|
import base64
|
||||||
import uuid
|
import uuid
|
||||||
import os
|
import os
|
||||||
from openpyxl.chart import (
|
from openpyxl.chart import LineChart, Reference
|
||||||
PieChart,
|
|
||||||
LineChart,
|
|
||||||
BarChart,
|
|
||||||
Reference,
|
|
||||||
)
|
|
||||||
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
||||||
from openpyxl.drawing.image import Image
|
from openpyxl.drawing.image import Image
|
||||||
from openpyxl import Workbook
|
from openpyxl import Workbook
|
||||||
|
|
|
@ -1,12 +1,8 @@
|
||||||
import base64
|
import base64
|
||||||
import uuid
|
import uuid
|
||||||
import os
|
import os
|
||||||
from openpyxl.chart import (
|
from decimal import Decimal
|
||||||
LineChart,
|
from openpyxl.chart import LineChart, PieChart, Reference
|
||||||
PieChart,
|
|
||||||
BarChart,
|
|
||||||
Reference,
|
|
||||||
)
|
|
||||||
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
||||||
from openpyxl.drawing.image import Image
|
from openpyxl.drawing.image import Image
|
||||||
from openpyxl import Workbook
|
from openpyxl import Workbook
|
||||||
|
@ -776,7 +772,7 @@ def generate_excel(report,
|
||||||
|
|
||||||
|
|
||||||
def sum_list(lists):
|
def sum_list(lists):
|
||||||
total = 0
|
total = Decimal(0)
|
||||||
|
|
||||||
for i in range(0, len(lists)):
|
for i in range(0, len(lists)):
|
||||||
total += lists[i]
|
total += lists[i]
|
||||||
|
|
|
@ -1,10 +1,7 @@
|
||||||
import base64
|
import base64
|
||||||
import uuid
|
import uuid
|
||||||
import os
|
import os
|
||||||
from openpyxl.chart import (
|
from openpyxl.chart import LineChart, Reference
|
||||||
LineChart,
|
|
||||||
Reference,
|
|
||||||
)
|
|
||||||
from openpyxl.chart.label import DataLabelList
|
from openpyxl.chart.label import DataLabelList
|
||||||
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
||||||
from openpyxl.drawing.image import Image
|
from openpyxl.drawing.image import Image
|
||||||
|
@ -160,152 +157,146 @@ def generate_excel(report,
|
||||||
####################################################################################################################
|
####################################################################################################################
|
||||||
reporting_period_data = report['reporting_period']
|
reporting_period_data = report['reporting_period']
|
||||||
|
|
||||||
has_energy_data_flag = True
|
|
||||||
|
|
||||||
if "names" not in reporting_period_data.keys() or \
|
if "names" not in reporting_period_data.keys() or \
|
||||||
reporting_period_data['names'] is None or \
|
reporting_period_data['names'] is None or \
|
||||||
len(reporting_period_data['names']) == 0:
|
len(reporting_period_data['names']) == 0:
|
||||||
has_energy_data_flag = False
|
|
||||||
|
|
||||||
filename = str(uuid.uuid4()) + '.xlsx'
|
filename = str(uuid.uuid4()) + '.xlsx'
|
||||||
wb.save(filename)
|
wb.save(filename)
|
||||||
|
|
||||||
return filename
|
return filename
|
||||||
|
|
||||||
if has_energy_data_flag:
|
ws['B6'].font = title_font
|
||||||
ws['B6'].font = title_font
|
ws['B6'] = name + ' 统计分析'
|
||||||
ws['B6'] = name + ' 统计分析'
|
|
||||||
|
|
||||||
category = reporting_period_data['names']
|
category = reporting_period_data['names']
|
||||||
|
|
||||||
# table_title
|
# table_title
|
||||||
ws['B7'].fill = table_fill
|
ws['B7'].fill = table_fill
|
||||||
ws['B7'].font = title_font
|
ws['B7'].font = title_font
|
||||||
ws['B7'].alignment = c_c_alignment
|
ws['B7'].alignment = c_c_alignment
|
||||||
ws['B7'] = '报告期'
|
ws['B7'] = '报告期'
|
||||||
ws['B7'].border = f_border
|
ws['B7'].border = f_border
|
||||||
|
|
||||||
ws['C7'].font = title_font
|
ws['C7'].font = title_font
|
||||||
ws['C7'].alignment = c_c_alignment
|
ws['C7'].alignment = c_c_alignment
|
||||||
ws['C7'] = '算术平均数'
|
ws['C7'] = '算术平均数'
|
||||||
ws['C7'].border = f_border
|
ws['C7'].border = f_border
|
||||||
|
|
||||||
ws['D7'].font = title_font
|
ws['D7'].font = title_font
|
||||||
ws['D7'].alignment = c_c_alignment
|
ws['D7'].alignment = c_c_alignment
|
||||||
ws['D7'] = '中位数'
|
ws['D7'] = '中位数'
|
||||||
ws['D7'].border = f_border
|
ws['D7'].border = f_border
|
||||||
|
|
||||||
ws['E7'].font = title_font
|
ws['E7'].font = title_font
|
||||||
ws['E7'].alignment = c_c_alignment
|
ws['E7'].alignment = c_c_alignment
|
||||||
ws['E7'] = '最小值'
|
ws['E7'] = '最小值'
|
||||||
ws['E7'].border = f_border
|
ws['E7'].border = f_border
|
||||||
|
|
||||||
ws['F7'].font = title_font
|
ws['F7'].font = title_font
|
||||||
ws['F7'].alignment = c_c_alignment
|
ws['F7'].alignment = c_c_alignment
|
||||||
ws['F7'] = '最大值'
|
ws['F7'] = '最大值'
|
||||||
ws['F7'].border = f_border
|
ws['F7'].border = f_border
|
||||||
|
|
||||||
ws['G7'].font = title_font
|
ws['G7'].font = title_font
|
||||||
ws['G7'].alignment = c_c_alignment
|
ws['G7'].alignment = c_c_alignment
|
||||||
ws['G7'] = '样本标准差'
|
ws['G7'] = '样本标准差'
|
||||||
ws['G7'].border = f_border
|
ws['G7'].border = f_border
|
||||||
|
|
||||||
ws['H7'].font = title_font
|
ws['H7'].font = title_font
|
||||||
ws['H7'].alignment = c_c_alignment
|
ws['H7'].alignment = c_c_alignment
|
||||||
ws['H7'] = '样本方差'
|
ws['H7'] = '样本方差'
|
||||||
ws['H7'].border = f_border
|
ws['H7'].border = f_border
|
||||||
|
|
||||||
# table_data
|
# table_data
|
||||||
|
|
||||||
for i, value in enumerate(category):
|
for i, value in enumerate(category):
|
||||||
row = i*2 + 8
|
row = i*2 + 8
|
||||||
ws['B' + str(row)].font = name_font
|
ws['B' + str(row)].font = name_font
|
||||||
ws['B' + str(row)].alignment = c_c_alignment
|
ws['B' + str(row)].alignment = c_c_alignment
|
||||||
ws['B' + str(row)] = reporting_period_data['names'][i] + " (" + reporting_period_data['units'][i] + " )"
|
ws['B' + str(row)] = reporting_period_data['names'][i] + " (" + reporting_period_data['units'][i] + " )"
|
||||||
ws['B' + str(row)].border = f_border
|
ws['B' + str(row)].border = f_border
|
||||||
|
|
||||||
ws['B' + str(row + 1)].font = name_font
|
ws['B' + str(row + 1)].font = name_font
|
||||||
ws['B' + str(row + 1)].alignment = c_c_alignment
|
ws['B' + str(row + 1)].alignment = c_c_alignment
|
||||||
ws['B' + str(row + 1)] = "环比"
|
ws['B' + str(row + 1)] = "环比"
|
||||||
ws['B' + str(row + 1)].border = f_border
|
ws['B' + str(row + 1)].border = f_border
|
||||||
|
|
||||||
ws['C' + str(row)].font = name_font
|
ws['C' + str(row)].font = name_font
|
||||||
ws['C' + str(row)].alignment = c_c_alignment
|
ws['C' + str(row)].alignment = c_c_alignment
|
||||||
ws['C' + str(row)] = round(reporting_period_data['means'][i], 2) \
|
ws['C' + str(row)] = round(reporting_period_data['means'][i], 2) \
|
||||||
if reporting_period_data['means'][i] is not None else ''
|
if reporting_period_data['means'][i] is not None else ''
|
||||||
ws['C' + str(row)].border = f_border
|
ws['C' + str(row)].border = f_border
|
||||||
ws['C' + str(row)].number_format = '0.00'
|
ws['C' + str(row)].number_format = '0.00'
|
||||||
|
|
||||||
ws['C' + str(row + 1)].font = name_font
|
ws['C' + str(row + 1)].font = name_font
|
||||||
ws['C' + str(row + 1)].alignment = c_c_alignment
|
ws['C' + str(row + 1)].alignment = c_c_alignment
|
||||||
ws['C' + str(row + 1)] = str(round(reporting_period_data['means_increment_rate'][i] * 100, 2)) + "%" \
|
ws['C' + str(row + 1)] = str(round(reporting_period_data['means_increment_rate'][i] * 100, 2)) + "%" \
|
||||||
if reporting_period_data['means_increment_rate'][i] is not None else '0.00%'
|
if reporting_period_data['means_increment_rate'][i] is not None else '0.00%'
|
||||||
ws['C' + str(row + 1)].border = f_border
|
ws['C' + str(row + 1)].border = f_border
|
||||||
|
|
||||||
ws['D' + str(row)].font = name_font
|
ws['D' + str(row)].font = name_font
|
||||||
ws['D' + str(row)].alignment = c_c_alignment
|
ws['D' + str(row)].alignment = c_c_alignment
|
||||||
ws['D' + str(row)] = round(reporting_period_data['medians'][i], 2) \
|
ws['D' + str(row)] = round(reporting_period_data['medians'][i], 2) \
|
||||||
if reporting_period_data['medians'][i] is not None else ''
|
if reporting_period_data['medians'][i] is not None else ''
|
||||||
ws['D' + str(row)].border = f_border
|
ws['D' + str(row)].border = f_border
|
||||||
ws['D' + str(row)].number_format = '0.00'
|
ws['D' + str(row)].number_format = '0.00'
|
||||||
|
|
||||||
ws['D' + str(row + 1)].font = name_font
|
ws['D' + str(row + 1)].font = name_font
|
||||||
ws['D' + str(row + 1)].alignment = c_c_alignment
|
ws['D' + str(row + 1)].alignment = c_c_alignment
|
||||||
ws['D' + str(row + 1)] = str(round(reporting_period_data['medians_increment_rate'][i] * 100, 2)) + "%" \
|
ws['D' + str(row + 1)] = str(round(reporting_period_data['medians_increment_rate'][i] * 100, 2)) + "%" \
|
||||||
if reporting_period_data['medians_increment_rate'][i] is not None else '0.00%'
|
if reporting_period_data['medians_increment_rate'][i] is not None else '0.00%'
|
||||||
ws['D' + str(row + 1)].border = f_border
|
ws['D' + str(row + 1)].border = f_border
|
||||||
|
|
||||||
ws['E' + str(row)].font = name_font
|
ws['E' + str(row)].font = name_font
|
||||||
ws['E' + str(row)].alignment = c_c_alignment
|
ws['E' + str(row)].alignment = c_c_alignment
|
||||||
ws['E' + str(row)] = round(reporting_period_data['minimums'][i], 2) \
|
ws['E' + str(row)] = round(reporting_period_data['minimums'][i], 2) \
|
||||||
if reporting_period_data['minimums'][i] is not None else ''
|
if reporting_period_data['minimums'][i] is not None else ''
|
||||||
ws['E' + str(row)].border = f_border
|
ws['E' + str(row)].border = f_border
|
||||||
ws['E' + str(row)].number_format = '0.00'
|
ws['E' + str(row)].number_format = '0.00'
|
||||||
|
|
||||||
ws['E' + str(row + 1)].font = name_font
|
ws['E' + str(row + 1)].font = name_font
|
||||||
ws['E' + str(row + 1)].alignment = c_c_alignment
|
ws['E' + str(row + 1)].alignment = c_c_alignment
|
||||||
ws['E' + str(row + 1)] = str(round(reporting_period_data['minimums_increment_rate'][i] * 100, 2)) + "%" \
|
ws['E' + str(row + 1)] = str(round(reporting_period_data['minimums_increment_rate'][i] * 100, 2)) + "%" \
|
||||||
if reporting_period_data['minimums_increment_rate'][i] is not None else '0.00%'
|
if reporting_period_data['minimums_increment_rate'][i] is not None else '0.00%'
|
||||||
ws['E' + str(row + 1)].border = f_border
|
ws['E' + str(row + 1)].border = f_border
|
||||||
|
|
||||||
ws['F' + str(row)].font = name_font
|
ws['F' + str(row)].font = name_font
|
||||||
ws['F' + str(row)].alignment = c_c_alignment
|
ws['F' + str(row)].alignment = c_c_alignment
|
||||||
ws['F' + str(row)] = round(reporting_period_data['maximums'][i], 2) \
|
ws['F' + str(row)] = round(reporting_period_data['maximums'][i], 2) \
|
||||||
if reporting_period_data['maximums'][i] is not None else ''
|
if reporting_period_data['maximums'][i] is not None else ''
|
||||||
ws['F' + str(row)].border = f_border
|
ws['F' + str(row)].border = f_border
|
||||||
ws['F' + str(row)].number_format = '0.00'
|
ws['F' + str(row)].number_format = '0.00'
|
||||||
|
|
||||||
ws['F' + str(row + 1)].font = name_font
|
ws['F' + str(row + 1)].font = name_font
|
||||||
ws['F' + str(row + 1)].alignment = c_c_alignment
|
ws['F' + str(row + 1)].alignment = c_c_alignment
|
||||||
ws['F' + str(row + 1)] = str(round(reporting_period_data['maximums_increment_rate'][i] * 100, 2)) + "%" \
|
ws['F' + str(row + 1)] = str(round(reporting_period_data['maximums_increment_rate'][i] * 100, 2)) + "%" \
|
||||||
if reporting_period_data['maximums_increment_rate'][i] is not None else '0.00%'
|
if reporting_period_data['maximums_increment_rate'][i] is not None else '0.00%'
|
||||||
ws['F' + str(row + 1)].border = f_border
|
ws['F' + str(row + 1)].border = f_border
|
||||||
|
|
||||||
ws['G' + str(row)].font = name_font
|
ws['G' + str(row)].font = name_font
|
||||||
ws['G' + str(row)].alignment = c_c_alignment
|
ws['G' + str(row)].alignment = c_c_alignment
|
||||||
ws['G' + str(row)] = round(reporting_period_data['stdevs'][i], 2) \
|
ws['G' + str(row)] = round(reporting_period_data['stdevs'][i], 2) \
|
||||||
if reporting_period_data['stdevs'][i] is not None else ''
|
if reporting_period_data['stdevs'][i] is not None else ''
|
||||||
ws['G' + str(row)].border = f_border
|
ws['G' + str(row)].border = f_border
|
||||||
ws['G' + str(row)].number_format = '0.00'
|
ws['G' + str(row)].number_format = '0.00'
|
||||||
|
|
||||||
ws['G' + str(row + 1)].font = name_font
|
ws['G' + str(row + 1)].font = name_font
|
||||||
ws['G' + str(row + 1)].alignment = c_c_alignment
|
ws['G' + str(row + 1)].alignment = c_c_alignment
|
||||||
ws['G' + str(row + 1)] = str(round(reporting_period_data['stdevs_increment_rate'][i] * 100, 2)) + "%" \
|
ws['G' + str(row + 1)] = str(round(reporting_period_data['stdevs_increment_rate'][i] * 100, 2)) + "%" \
|
||||||
if reporting_period_data['stdevs_increment_rate'][i] is not None else '0.00%'
|
if reporting_period_data['stdevs_increment_rate'][i] is not None else '0.00%'
|
||||||
ws['G' + str(row + 1)].border = f_border
|
ws['G' + str(row + 1)].border = f_border
|
||||||
|
|
||||||
ws['H' + str(row)].font = name_font
|
ws['H' + str(row)].font = name_font
|
||||||
ws['H' + str(row)].alignment = c_c_alignment
|
ws['H' + str(row)].alignment = c_c_alignment
|
||||||
ws['H' + str(row)] = round(reporting_period_data['variances'][i], 2) \
|
ws['H' + str(row)] = round(reporting_period_data['variances'][i], 2) \
|
||||||
if reporting_period_data['variances'][i] is not None else ''
|
if reporting_period_data['variances'][i] is not None else ''
|
||||||
ws['H' + str(row)].border = f_border
|
ws['H' + str(row)].border = f_border
|
||||||
ws['H' + str(row)].number_format = '0.00'
|
ws['H' + str(row)].number_format = '0.00'
|
||||||
|
|
||||||
ws['H' + str(row + 1)].font = name_font
|
ws['H' + str(row + 1)].font = name_font
|
||||||
ws['H' + str(row + 1)].alignment = c_c_alignment
|
ws['H' + str(row + 1)].alignment = c_c_alignment
|
||||||
ws['H' + str(row + 1)] = str(round(reporting_period_data['variances_increment_rate'][i] * 100, 2)) + "%" \
|
ws['H' + str(row + 1)] = str(round(reporting_period_data['variances_increment_rate'][i] * 100, 2)) + "%" \
|
||||||
if reporting_period_data['variances_increment_rate'][i] is not None else '0.00%'
|
if reporting_period_data['variances_increment_rate'][i] is not None else '0.00%'
|
||||||
ws['H' + str(row + 1)].border = f_border
|
ws['H' + str(row + 1)].border = f_border
|
||||||
####################################################################################################################
|
####################################################################################################################
|
||||||
# Second: 报告期消耗
|
# Second: 报告期消耗
|
||||||
# 9 + ca_len * 2: title
|
# 9 + ca_len * 2: title
|
||||||
|
@ -313,111 +304,110 @@ def generate_excel(report,
|
||||||
# per_unit_area_start_row_number + 2 ~ per_unit_area_start_row_number + 2 + ca_len : table_data
|
# per_unit_area_start_row_number + 2 ~ per_unit_area_start_row_number + 2 + ca_len : table_data
|
||||||
####################################################################################################################
|
####################################################################################################################
|
||||||
|
|
||||||
if has_energy_data_flag:
|
names = reporting_period_data['names']
|
||||||
names = reporting_period_data['names']
|
ca_len = len(names)
|
||||||
ca_len = len(names)
|
|
||||||
|
|
||||||
per_unit_area_start_row_number = 9 + ca_len * 2
|
per_unit_area_start_row_number = 9 + ca_len * 2
|
||||||
|
|
||||||
ws['B' + str(per_unit_area_start_row_number)].font = title_font
|
ws['B' + str(per_unit_area_start_row_number)].font = title_font
|
||||||
ws['B' + str(per_unit_area_start_row_number)] = name + ' 单位面积值' + str(report['tenant']['area']) + 'M²'
|
ws['B' + str(per_unit_area_start_row_number)] = name + ' 单位面积值' + str(report['tenant']['area']) + 'M²'
|
||||||
|
|
||||||
category = reporting_period_data['names']
|
category = reporting_period_data['names']
|
||||||
|
|
||||||
# table_title
|
# table_title
|
||||||
ws['B' + str(per_unit_area_start_row_number + 1)].fill = table_fill
|
ws['B' + str(per_unit_area_start_row_number + 1)].fill = table_fill
|
||||||
ws['B' + str(per_unit_area_start_row_number + 1)].font = title_font
|
ws['B' + str(per_unit_area_start_row_number + 1)].font = title_font
|
||||||
ws['B' + str(per_unit_area_start_row_number + 1)].alignment = c_c_alignment
|
ws['B' + str(per_unit_area_start_row_number + 1)].alignment = c_c_alignment
|
||||||
ws['B' + str(per_unit_area_start_row_number + 1)] = '报告期'
|
ws['B' + str(per_unit_area_start_row_number + 1)] = '报告期'
|
||||||
ws['B' + str(per_unit_area_start_row_number + 1)].border = f_border
|
ws['B' + str(per_unit_area_start_row_number + 1)].border = f_border
|
||||||
|
|
||||||
ws['C' + str(per_unit_area_start_row_number + 1)].font = title_font
|
ws['C' + str(per_unit_area_start_row_number + 1)].font = title_font
|
||||||
ws['C' + str(per_unit_area_start_row_number + 1)].alignment = c_c_alignment
|
ws['C' + str(per_unit_area_start_row_number + 1)].alignment = c_c_alignment
|
||||||
ws['C' + str(per_unit_area_start_row_number + 1)] = '算术平均数'
|
ws['C' + str(per_unit_area_start_row_number + 1)] = '算术平均数'
|
||||||
ws['C' + str(per_unit_area_start_row_number + 1)].border = f_border
|
ws['C' + str(per_unit_area_start_row_number + 1)].border = f_border
|
||||||
|
|
||||||
ws['D' + str(per_unit_area_start_row_number + 1)].font = title_font
|
ws['D' + str(per_unit_area_start_row_number + 1)].font = title_font
|
||||||
ws['D' + str(per_unit_area_start_row_number + 1)].alignment = c_c_alignment
|
ws['D' + str(per_unit_area_start_row_number + 1)].alignment = c_c_alignment
|
||||||
ws['D' + str(per_unit_area_start_row_number + 1)] = '中位数'
|
ws['D' + str(per_unit_area_start_row_number + 1)] = '中位数'
|
||||||
ws['D' + str(per_unit_area_start_row_number + 1)].border = f_border
|
ws['D' + str(per_unit_area_start_row_number + 1)].border = f_border
|
||||||
|
|
||||||
ws['E' + str(per_unit_area_start_row_number + 1)].font = title_font
|
ws['E' + str(per_unit_area_start_row_number + 1)].font = title_font
|
||||||
ws['E' + str(per_unit_area_start_row_number + 1)].alignment = c_c_alignment
|
ws['E' + str(per_unit_area_start_row_number + 1)].alignment = c_c_alignment
|
||||||
ws['E' + str(per_unit_area_start_row_number + 1)] = '最小值'
|
ws['E' + str(per_unit_area_start_row_number + 1)] = '最小值'
|
||||||
ws['E' + str(per_unit_area_start_row_number + 1)].border = f_border
|
ws['E' + str(per_unit_area_start_row_number + 1)].border = f_border
|
||||||
|
|
||||||
ws['F' + str(per_unit_area_start_row_number + 1)].font = title_font
|
ws['F' + str(per_unit_area_start_row_number + 1)].font = title_font
|
||||||
ws['F' + str(per_unit_area_start_row_number + 1)].alignment = c_c_alignment
|
ws['F' + str(per_unit_area_start_row_number + 1)].alignment = c_c_alignment
|
||||||
ws['F' + str(per_unit_area_start_row_number + 1)] = '最大值'
|
ws['F' + str(per_unit_area_start_row_number + 1)] = '最大值'
|
||||||
ws['F' + str(per_unit_area_start_row_number + 1)].border = f_border
|
ws['F' + str(per_unit_area_start_row_number + 1)].border = f_border
|
||||||
|
|
||||||
ws['G' + str(per_unit_area_start_row_number + 1)].font = title_font
|
ws['G' + str(per_unit_area_start_row_number + 1)].font = title_font
|
||||||
ws['G' + str(per_unit_area_start_row_number + 1)].alignment = c_c_alignment
|
ws['G' + str(per_unit_area_start_row_number + 1)].alignment = c_c_alignment
|
||||||
ws['G' + str(per_unit_area_start_row_number + 1)] = '样本标准差'
|
ws['G' + str(per_unit_area_start_row_number + 1)] = '样本标准差'
|
||||||
ws['G' + str(per_unit_area_start_row_number + 1)].border = f_border
|
ws['G' + str(per_unit_area_start_row_number + 1)].border = f_border
|
||||||
|
|
||||||
ws['H' + str(per_unit_area_start_row_number + 1)].font = title_font
|
ws['H' + str(per_unit_area_start_row_number + 1)].font = title_font
|
||||||
ws['H' + str(per_unit_area_start_row_number + 1)].alignment = c_c_alignment
|
ws['H' + str(per_unit_area_start_row_number + 1)].alignment = c_c_alignment
|
||||||
ws['H' + str(per_unit_area_start_row_number + 1)] = '样本方差'
|
ws['H' + str(per_unit_area_start_row_number + 1)] = '样本方差'
|
||||||
ws['H' + str(per_unit_area_start_row_number + 1)].border = f_border
|
ws['H' + str(per_unit_area_start_row_number + 1)].border = f_border
|
||||||
|
|
||||||
# table_data
|
# table_data
|
||||||
|
|
||||||
for i, value in enumerate(category):
|
for i, value in enumerate(category):
|
||||||
row_data = per_unit_area_start_row_number + 2 + i
|
row_data = per_unit_area_start_row_number + 2 + i
|
||||||
ws['B' + str(row_data)].font = name_font
|
ws['B' + str(row_data)].font = name_font
|
||||||
ws['B' + str(row_data)].alignment = c_c_alignment
|
ws['B' + str(row_data)].alignment = c_c_alignment
|
||||||
ws['B' + str(row_data)] = reporting_period_data['names'][i] + " (" + reporting_period_data['units'][
|
ws['B' + str(row_data)] = reporting_period_data['names'][i] + " (" + reporting_period_data['units'][
|
||||||
i] + "/M²)"
|
i] + "/M²)"
|
||||||
ws['B' + str(row_data)].border = f_border
|
ws['B' + str(row_data)].border = f_border
|
||||||
|
|
||||||
ws['C' + str(row_data)].font = name_font
|
ws['C' + str(row_data)].font = name_font
|
||||||
ws['C' + str(row_data)].alignment = c_c_alignment
|
ws['C' + str(row_data)].alignment = c_c_alignment
|
||||||
if reporting_period_data['means_per_unit_area'][i] \
|
if reporting_period_data['means_per_unit_area'][i] \
|
||||||
or reporting_period_data['means_per_unit_area'][i] == 0:
|
or reporting_period_data['means_per_unit_area'][i] == 0:
|
||||||
ws['C' + str(row_data)] = round(reporting_period_data['means_per_unit_area'][i], 2)
|
ws['C' + str(row_data)] = round(reporting_period_data['means_per_unit_area'][i], 2)
|
||||||
ws['C' + str(row_data)].border = f_border
|
ws['C' + str(row_data)].border = f_border
|
||||||
ws['C' + str(row_data)].number_format = '0.00'
|
ws['C' + str(row_data)].number_format = '0.00'
|
||||||
|
|
||||||
ws['D' + str(row_data)].font = name_font
|
ws['D' + str(row_data)].font = name_font
|
||||||
ws['D' + str(row_data)].alignment = c_c_alignment
|
ws['D' + str(row_data)].alignment = c_c_alignment
|
||||||
if reporting_period_data['medians_per_unit_area'][i] \
|
if reporting_period_data['medians_per_unit_area'][i] \
|
||||||
or reporting_period_data['medians_per_unit_area'][i] == 0:
|
or reporting_period_data['medians_per_unit_area'][i] == 0:
|
||||||
ws['D' + str(row_data)] = round(reporting_period_data['medians_per_unit_area'][i], 2)
|
ws['D' + str(row_data)] = round(reporting_period_data['medians_per_unit_area'][i], 2)
|
||||||
ws['D' + str(row_data)].border = f_border
|
ws['D' + str(row_data)].border = f_border
|
||||||
ws['D' + str(row_data)].number_format = '0.00'
|
ws['D' + str(row_data)].number_format = '0.00'
|
||||||
|
|
||||||
ws['E' + str(row_data)].font = name_font
|
ws['E' + str(row_data)].font = name_font
|
||||||
ws['E' + str(row_data)].alignment = c_c_alignment
|
ws['E' + str(row_data)].alignment = c_c_alignment
|
||||||
if reporting_period_data['minimums_per_unit_area'][i] \
|
if reporting_period_data['minimums_per_unit_area'][i] \
|
||||||
or reporting_period_data['minimums_per_unit_area'][i] == 0:
|
or reporting_period_data['minimums_per_unit_area'][i] == 0:
|
||||||
ws['E' + str(row_data)] = round(reporting_period_data['minimums_per_unit_area'][i], 2)
|
ws['E' + str(row_data)] = round(reporting_period_data['minimums_per_unit_area'][i], 2)
|
||||||
ws['E' + str(row_data)].border = f_border
|
ws['E' + str(row_data)].border = f_border
|
||||||
ws['E' + str(row_data)].number_format = '0.00'
|
ws['E' + str(row_data)].number_format = '0.00'
|
||||||
|
|
||||||
ws['F' + str(row_data)].font = name_font
|
ws['F' + str(row_data)].font = name_font
|
||||||
ws['F' + str(row_data)].alignment = c_c_alignment
|
ws['F' + str(row_data)].alignment = c_c_alignment
|
||||||
if reporting_period_data['maximums_per_unit_area'][i] \
|
if reporting_period_data['maximums_per_unit_area'][i] \
|
||||||
or reporting_period_data['maximums_per_unit_area'][i] == 0:
|
or reporting_period_data['maximums_per_unit_area'][i] == 0:
|
||||||
ws['F' + str(row_data)] = round(reporting_period_data['maximums_per_unit_area'][i], 2)
|
ws['F' + str(row_data)] = round(reporting_period_data['maximums_per_unit_area'][i], 2)
|
||||||
ws['F' + str(row_data)].border = f_border
|
ws['F' + str(row_data)].border = f_border
|
||||||
ws['F' + str(row_data)].number_format = '0.00'
|
ws['F' + str(row_data)].number_format = '0.00'
|
||||||
|
|
||||||
ws['G' + str(row_data)].font = name_font
|
ws['G' + str(row_data)].font = name_font
|
||||||
ws['G' + str(row_data)].alignment = c_c_alignment
|
ws['G' + str(row_data)].alignment = c_c_alignment
|
||||||
if (reporting_period_data['stdevs_per_unit_area'][i]) \
|
if (reporting_period_data['stdevs_per_unit_area'][i]) \
|
||||||
or reporting_period_data['stdevs_per_unit_area'][i] == 0:
|
or reporting_period_data['stdevs_per_unit_area'][i] == 0:
|
||||||
ws['G' + str(row_data)] = round(reporting_period_data['stdevs_per_unit_area'][i], 2)
|
ws['G' + str(row_data)] = round(reporting_period_data['stdevs_per_unit_area'][i], 2)
|
||||||
ws['G' + str(row_data)].border = f_border
|
ws['G' + str(row_data)].border = f_border
|
||||||
ws['G' + str(row_data)].number_format = '0.00'
|
ws['G' + str(row_data)].number_format = '0.00'
|
||||||
|
|
||||||
ws['H' + str(row_data)].font = name_font
|
ws['H' + str(row_data)].font = name_font
|
||||||
ws['H' + str(row_data)].alignment = c_c_alignment
|
ws['H' + str(row_data)].alignment = c_c_alignment
|
||||||
if reporting_period_data['variances_per_unit_area'][i] \
|
if reporting_period_data['variances_per_unit_area'][i] \
|
||||||
or reporting_period_data['variances_per_unit_area'][i] == 0:
|
or reporting_period_data['variances_per_unit_area'][i] == 0:
|
||||||
ws['H' + str(row_data)] = round(reporting_period_data['variances_per_unit_area'][i], 2)
|
ws['H' + str(row_data)] = round(reporting_period_data['variances_per_unit_area'][i], 2)
|
||||||
ws['H' + str(row_data)].border = f_border
|
ws['H' + str(row_data)].border = f_border
|
||||||
ws['H' + str(row_data)].number_format = '0.00'
|
ws['H' + str(row_data)].number_format = '0.00'
|
||||||
|
|
||||||
####################################################################################################################
|
####################################################################################################################
|
||||||
# Third: 详细数据
|
# Third: 详细数据
|
||||||
|
|
|
@ -1,12 +1,7 @@
|
||||||
import base64
|
import base64
|
||||||
import uuid
|
import uuid
|
||||||
import os
|
import os
|
||||||
from openpyxl.chart import (
|
from openpyxl.chart import LineChart, Reference, Series
|
||||||
LineChart,
|
|
||||||
BarChart,
|
|
||||||
Reference,
|
|
||||||
Series
|
|
||||||
)
|
|
||||||
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
||||||
from openpyxl.drawing.image import Image
|
from openpyxl.drawing.image import Image
|
||||||
from openpyxl import Workbook
|
from openpyxl import Workbook
|
||||||
|
|
|
@ -1,14 +1,8 @@
|
||||||
import base64
|
import base64
|
||||||
import os
|
import os
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from openpyxl import Workbook
|
from openpyxl import Workbook
|
||||||
from openpyxl.chart import (
|
from openpyxl.chart import LineChart, Reference, Series
|
||||||
LineChart,
|
|
||||||
BarChart,
|
|
||||||
Reference,
|
|
||||||
Series,
|
|
||||||
)
|
|
||||||
from openpyxl.chart.label import DataLabelList
|
from openpyxl.chart.label import DataLabelList
|
||||||
from openpyxl.drawing.image import Image
|
from openpyxl.drawing.image import Image
|
||||||
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
from openpyxl.styles import PatternFill, Border, Side, Alignment, Font
|
||||||
|
|
Loading…
Reference in New Issue