fixed NoneType issues in ExcelExporters
parent
60d772ee1b
commit
e55ea48ef5
|
@ -199,7 +199,7 @@ def generate_excel(report,
|
|||
|
||||
max_row = start_detail_data_row_num + len(time)
|
||||
ws['B6'].font = title_font
|
||||
ws['B6'] = name + ' ' + '趋势'
|
||||
ws['B6'] = name + ' ' + 'Trend'
|
||||
|
||||
ws.row_dimensions[start_detail_data_row_num - 1].height = 60
|
||||
ws['B' + str(start_detail_data_row_num - 1)].fill = table_fill
|
||||
|
@ -233,12 +233,13 @@ def generate_excel(report,
|
|||
ws[col + row].alignment = c_c_alignment
|
||||
ws[col + row] = round(reporting_period_data['values'][i][j], 3) if \
|
||||
len(reporting_period_data['values'][i]) > 0 and \
|
||||
reporting_period_data['values'][i][j] is not None else " "
|
||||
len(reporting_period_data['values'][i]) > j and \
|
||||
reporting_period_data['values'][i][j] is not None else ''
|
||||
ws[col + row].border = f_border
|
||||
# line
|
||||
# 39~: line
|
||||
line = LineChart()
|
||||
line.title = '趋势值 - ' + reporting_period_data['names'][i]
|
||||
line.title = 'Trend Value - ' + reporting_period_data['names'][i]
|
||||
labels = Reference(ws, min_col=2, min_row=start_detail_data_row_num, max_row=max_row-1)
|
||||
line_data = Reference(ws, min_col=3 + i, min_row=start_detail_data_row_num+1, max_row=max_row-1)
|
||||
line.add_data(line_data, titles_from_data=True)
|
||||
|
|
|
@ -209,13 +209,14 @@ def generate_excel(report,
|
|||
|
||||
ws[col + '9'].font = name_font
|
||||
ws[col + '9'].alignment = c_c_alignment
|
||||
ws[col + '9'] = round(reporting_period_data['subtotals_per_unit_area'][i], 2)
|
||||
ws[col + '9'] = round(reporting_period_data['subtotals_per_unit_area'][i], 2) \
|
||||
if reporting_period_data['subtotals_per_unit_area'][i] is not None else ''
|
||||
ws[col + '9'].border = f_border
|
||||
|
||||
ws[col + '10'].font = name_font
|
||||
ws[col + '10'].alignment = c_c_alignment
|
||||
ws[col + '10'] = str(round(reporting_period_data['increment_rates'][i] * 100, 2)) + "%" \
|
||||
if reporting_period_data['increment_rates'][i] is not None else "-"
|
||||
if reporting_period_data['increment_rates'][i] is not None else ''
|
||||
ws[col + '10'].border = f_border
|
||||
|
||||
# TCE TCO2E
|
||||
|
@ -235,13 +236,14 @@ def generate_excel(report,
|
|||
|
||||
ws[tce_col + '9'].font = name_font
|
||||
ws[tce_col + '9'].alignment = c_c_alignment
|
||||
ws[tce_col + '9'] = round(reporting_period_data['total_in_kgce_per_unit_area'] / 1000, 2)
|
||||
ws[tce_col + '9'] = round(reporting_period_data['total_in_kgce_per_unit_area'] / 1000, 2) \
|
||||
if reporting_period_data['total_in_kgce_per_unit_area'] is not None else ''
|
||||
ws[tce_col + '9'].border = f_border
|
||||
|
||||
ws[tce_col + '10'].font = name_font
|
||||
ws[tce_col + '10'].alignment = c_c_alignment
|
||||
ws[tce_col + '10'] = str(round(reporting_period_data['increment_rate_in_kgce'] * 100, 2)) + "%" \
|
||||
if reporting_period_data['increment_rate_in_kgce'] is not None else "-"
|
||||
if reporting_period_data['increment_rate_in_kgce'] is not None else ''
|
||||
ws[tce_col + '10'].border = f_border
|
||||
|
||||
# TCO2E
|
||||
|
@ -259,13 +261,14 @@ def generate_excel(report,
|
|||
|
||||
ws[tco2e_col + '9'].font = name_font
|
||||
ws[tco2e_col + '9'].alignment = c_c_alignment
|
||||
ws[tco2e_col + '9'] = round(reporting_period_data['total_in_kgco2e_per_unit_area'] / 1000, 2)
|
||||
ws[tco2e_col + '9'] = round(reporting_period_data['total_in_kgco2e_per_unit_area'] / 1000, 2) \
|
||||
if reporting_period_data['total_in_kgco2e_per_unit_area'] is not None else ''
|
||||
ws[tco2e_col + '9'].border = f_border
|
||||
|
||||
ws[tco2e_col + '10'].font = name_font
|
||||
ws[tco2e_col + '10'].alignment = c_c_alignment
|
||||
ws[tco2e_col + '10'] = str(round(reporting_period_data['increment_rate_in_kgco2e'] * 100, 2)) + "%" \
|
||||
if reporting_period_data['increment_rate_in_kgco2e'] is not None else "-"
|
||||
if reporting_period_data['increment_rate_in_kgco2e'] is not None else ''
|
||||
ws[tco2e_col + '10'].border = f_border
|
||||
else:
|
||||
for i in range(6, 10 + 1):
|
||||
|
|
|
@ -210,7 +210,8 @@ def generate_excel(report,
|
|||
|
||||
ws[col + '8'].font = name_font
|
||||
ws[col + '8'].alignment = c_c_alignment
|
||||
ws[col + '8'] = round(reporting_period_data['subtotals_per_unit_area'][i], 2)
|
||||
ws[col + '8'] = round(reporting_period_data['subtotals_per_unit_area'][i], 2) \
|
||||
if reporting_period_data['subtotals_per_unit_area'][i] is not None else ''
|
||||
ws[col + '8'].border = f_border
|
||||
|
||||
ws[col + '9'].font = name_font
|
||||
|
@ -234,7 +235,8 @@ def generate_excel(report,
|
|||
|
||||
ws[col + '8'].font = name_font
|
||||
ws[col + '8'].alignment = c_c_alignment
|
||||
ws[col + '8'] = round(reporting_period_data['total_per_unit_area'], 2)
|
||||
ws[col + '8'] = round(reporting_period_data['total_per_unit_area'], 2) \
|
||||
if reporting_period_data['total_per_unit_area'] is not None else ''
|
||||
ws[col + '8'].border = f_border
|
||||
|
||||
ws[col + '9'].font = name_font
|
||||
|
|
|
@ -222,7 +222,8 @@ def generate_excel(report,
|
|||
ws[col + str(current_row_number)].font = name_font
|
||||
ws[col + str(current_row_number)].alignment = c_c_alignment
|
||||
ws[col + str(current_row_number)].border = f_border
|
||||
ws[col + str(current_row_number)] = round(reporting_period_data['subtotals_per_unit_area'][i], 2)
|
||||
ws[col + str(current_row_number)] = round(reporting_period_data['subtotals_per_unit_area'][i], 2) \
|
||||
if reporting_period_data['subtotals_per_unit_area'][i] is not None else ''
|
||||
|
||||
col = chr(ord(col) + 1)
|
||||
|
||||
|
|
|
@ -254,14 +254,8 @@ def generate_excel(report,
|
|||
ws[col + str(current_row_number)].font = name_font
|
||||
ws[col + str(current_row_number)].alignment = c_c_alignment
|
||||
ws[col + str(current_row_number)].border = f_border
|
||||
ws[col + str(current_row_number)] = round(reporting_period_data['subtotals_per_unit_area_saving'][i], 2)
|
||||
|
||||
col = chr(ord(col) + 1)
|
||||
|
||||
ws[col + str(current_row_number)].font = name_font
|
||||
ws[col + str(current_row_number)].alignment = c_c_alignment
|
||||
ws[col + str(current_row_number)].border = f_border
|
||||
ws[col + str(current_row_number)] = round(reporting_period_data['total_in_kgce_per_unit_area_saving'] / 1000, 2)
|
||||
ws[col + str(current_row_number)] = round(reporting_period_data['subtotals_per_unit_area_saving'][i], 2) \
|
||||
if reporting_period_data['subtotals_per_unit_area_saving'][i] is not None else ''
|
||||
|
||||
col = chr(ord(col) + 1)
|
||||
|
||||
|
@ -269,7 +263,17 @@ def generate_excel(report,
|
|||
ws[col + str(current_row_number)].alignment = c_c_alignment
|
||||
ws[col + str(current_row_number)].border = f_border
|
||||
ws[col + str(current_row_number)] = \
|
||||
round(reporting_period_data['total_in_kgco2e_per_unit_area_saving'] / 1000, 2)
|
||||
round(reporting_period_data['total_in_kgce_per_unit_area_saving'] / 1000, 2) \
|
||||
if reporting_period_data['total_in_kgce_per_unit_area_saving'] is not None else ''
|
||||
|
||||
col = chr(ord(col) + 1)
|
||||
|
||||
ws[col + str(current_row_number)].font = name_font
|
||||
ws[col + str(current_row_number)].alignment = c_c_alignment
|
||||
ws[col + str(current_row_number)].border = f_border
|
||||
ws[col + str(current_row_number)] = \
|
||||
round(reporting_period_data['total_in_kgco2e_per_unit_area_saving'] / 1000, 2) \
|
||||
if reporting_period_data['total_in_kgco2e_per_unit_area_saving'] is not None else ''
|
||||
|
||||
col = chr(ord(col) + 1)
|
||||
|
||||
|
|
Loading…
Reference in New Issue