Code Duplication    Length = 78-80 lines in 2 locations

excelexporters/spacecost.py 1 location

@@ 185-264 (lines=80) @@
182
            len(reporting_period_data['names']) == 0:
183
        has_cost_data_flag = False
184
185
    if has_cost_data_flag:
186
        ws['B6'].font = title_font
187
        ws['B6'] = name + ' 报告期成本'
188
189
        category = reporting_period_data['names']
190
        ca_len = len(category)
191
192
        ws.row_dimensions[7].height = 60
193
        ws['B7'].fill = table_fill
194
        ws['B7'].border = f_border
195
196
        ws['B8'].font = title_font
197
        ws['B8'].alignment = c_c_alignment
198
        ws['B8'] = '成本'
199
        ws['B8'].border = f_border
200
201
        ws['B9'].font = title_font
202
        ws['B9'].alignment = c_c_alignment
203
        ws['B9'] = '单位面积值'
204
        ws['B9'].border = f_border
205
206
        ws['B10'].font = title_font
207
        ws['B10'].alignment = c_c_alignment
208
        ws['B10'] = '环比'
209
        ws['B10'].border = f_border
210
211
        col = ''
212
213
        for i in range(0, ca_len):
214
            col = chr(ord('C') + i)
215
216
            ws[col + '7'].fill = table_fill
217
            ws[col + '7'].font = name_font
218
            ws[col + '7'].alignment = c_c_alignment
219
            ws[col + '7'] = reporting_period_data['names'][i] + " (" + reporting_period_data['units'][i] + ")"
220
            ws[col + '7'].border = f_border
221
222
            ws[col + '8'].font = name_font
223
            ws[col + '8'].alignment = c_c_alignment
224
            ws[col + '8'] = round(reporting_period_data['subtotals'][i], 2)
225
            ws[col + '8'].border = f_border
226
227
            ws[col + '9'].font = name_font
228
            ws[col + '9'].alignment = c_c_alignment
229
            ws[col + '9'] = round(reporting_period_data['subtotals_per_unit_area'][i], 2)
230
            ws[col + '9'].border = f_border
231
232
            ws[col + '10'].font = name_font
233
            ws[col + '10'].alignment = c_c_alignment
234
            ws[col + '10'] = str(round(reporting_period_data['increment_rates'][i] * 100, 2)) + "%" \
235
                if reporting_period_data['increment_rates'][i] is not None else "-"
236
            ws[col + '10'].border = f_border
237
238
        col = chr(ord(col) + 1)
239
240
        ws[col + '7'].fill = table_fill
241
        ws[col + '7'].font = name_font
242
        ws[col + '7'].alignment = c_c_alignment
243
        ws[col + '7'] = "总计 (" + reporting_period_data['total_unit'] + ")"
244
        ws[col + '7'].border = f_border
245
246
        ws[col + '8'].font = name_font
247
        ws[col + '8'].alignment = c_c_alignment
248
        ws[col + '8'] = round(reporting_period_data['total'], 2)
249
        ws[col + '8'].border = f_border
250
251
        ws[col + '9'].font = name_font
252
        ws[col + '9'].alignment = c_c_alignment
253
        ws[col + '9'] = round(reporting_period_data['total_per_unit_area'], 2)
254
        ws[col + '9'].border = f_border
255
256
        ws[col + '10'].font = name_font
257
        ws[col + '10'].alignment = c_c_alignment
258
        ws[col + '10'] = str(round(reporting_period_data['total_increment_rate'] * 100, 2)) + "%" \
259
            if reporting_period_data['total_increment_rate'] is not None else "-"
260
        ws[col + '10'].border = f_border
261
262
    else:
263
        for i in range(6, 10 + 1):
264
            ws.row_dimensions[i].height = 0.1
265
266
    ##############################
267

excelexporters/tenantcost.py 1 location

@@ 183-260 (lines=78) @@
180
            len(reporting_period_data['names']) == 0:
181
        has_energy_data_flag = False
182
183
    if has_energy_data_flag:
184
        ws['B6'].font = title_font
185
        ws['B6'] = name+' 报告期成本'
186
187
        category = reporting_period_data['names']
188
        ca_len = len(category)
189
190
        ws.row_dimensions[7].height = 60
191
        ws['B7'].fill = table_fill
192
        ws['B7'].border = f_border
193
194
        ws['B8'].font = title_font
195
        ws['B8'].alignment = c_c_alignment
196
        ws['B8'] = '成本'
197
        ws['B8'].border = f_border
198
199
        ws['B9'].font = title_font
200
        ws['B9'].alignment = c_c_alignment
201
        ws['B9'] = '单位面积能耗'
202
        ws['B9'].border = f_border
203
204
        ws['B10'].font = title_font
205
        ws['B10'].alignment = c_c_alignment
206
        ws['B10'] = '环比'
207
        ws['B10'].border = f_border
208
209
        col = 'B'
210
211
        for i in range(0, ca_len):
212
            col = chr(ord('C') + i)
213
            ws[col + '7'].fill = table_fill
214
            ws[col + '7'].font = name_font
215
            ws[col + '7'].alignment = c_c_alignment
216
            ws[col + '7'] = reporting_period_data['names'][i] + " (" + reporting_period_data['units'][i] + ")"
217
            ws[col + '7'].border = f_border
218
219
            ws[col + '8'].font = name_font
220
            ws[col + '8'].alignment = c_c_alignment
221
            ws[col + '8'] = round(reporting_period_data['subtotals'][i], 2)
222
            ws[col + '8'].border = f_border
223
224
            ws[col + '9'].font = name_font
225
            ws[col + '9'].alignment = c_c_alignment
226
            ws[col + '9'] = round(reporting_period_data['subtotals_per_unit_area'][i], 2)
227
            ws[col + '9'].border = f_border
228
229
            ws[col + '10'].font = name_font
230
            ws[col + '10'].alignment = c_c_alignment
231
            ws[col + '10'] = str(round(reporting_period_data['increment_rates'][i] * 100, 2)) + "%" \
232
                if reporting_period_data['increment_rates'][i] is not None else "-"
233
            ws[col + '10'].border = f_border
234
235
        end_col = chr(ord(col)+1)
236
        ws[end_col + '7'].fill = table_fill
237
        ws[end_col + '7'].font = name_font
238
        ws[end_col + '7'].alignment = c_c_alignment
239
        ws[end_col + '7'] = "总计 (" + reporting_period_data['total_unit'] + ")"
240
        ws[end_col + '7'].border = f_border
241
242
        ws[end_col + '8'].font = name_font
243
        ws[end_col + '8'].alignment = c_c_alignment
244
        ws[end_col + '8'] = round(reporting_period_data['total'], 2)
245
        ws[end_col + '8'].border = f_border
246
247
        ws[end_col + '9'].font = name_font
248
        ws[end_col + '9'].alignment = c_c_alignment
249
        ws[end_col + '9'] = round(reporting_period_data['total_per_unit_area'], 2)
250
        ws[end_col + '9'].border = f_border
251
252
        ws[end_col + '10'].font = name_font
253
        ws[end_col + '10'].alignment = c_c_alignment
254
        ws[end_col + '10'] = str(round(reporting_period_data['total_increment_rate'] * 100, 2)) + "%" \
255
            if reporting_period_data['total_increment_rate'] is not None else "-"
256
        ws[end_col + '10'].border = f_border
257
258
    else:
259
        for i in range(6, 10 + 1):
260
            ws.row_dimensions[i].height = 0.1
261
262
    #################################################
263