| @@ 344-403 (lines=60) @@ | ||
| 341 | len(reporting_period_data['subtotals']) == 0: |
|
| 342 | has_subtotals_data_flag = False |
|
| 343 | ||
| 344 | if has_subtotals_data_flag: |
|
| 345 | ws['B' + str(current_row_number)].font = title_font |
|
| 346 | ws['B' + str(current_row_number)] = name + ' 成本占比' |
|
| 347 | ||
| 348 | current_row_number += 1 |
|
| 349 | ||
| 350 | table_start_row_number = current_row_number |
|
| 351 | ||
| 352 | ws['B' + str(current_row_number)].fill = table_fill |
|
| 353 | ws['B' + str(current_row_number)].font = name_font |
|
| 354 | ws['B' + str(current_row_number)].alignment = c_c_alignment |
|
| 355 | ws['B' + str(current_row_number)].border = f_border |
|
| 356 | ||
| 357 | ws['C' + str(current_row_number)].fill = table_fill |
|
| 358 | ws['C' + str(current_row_number)].font = name_font |
|
| 359 | ws['C' + str(current_row_number)].alignment = c_c_alignment |
|
| 360 | ws['C' + str(current_row_number)].border = f_border |
|
| 361 | ws['C' + str(current_row_number)] = '成本占比' |
|
| 362 | ||
| 363 | current_row_number += 1 |
|
| 364 | ||
| 365 | ca_len = len(reporting_period_data['names']) |
|
| 366 | ||
| 367 | for i in range(0, ca_len): |
|
| 368 | ws['B' + str(current_row_number)].font = title_font |
|
| 369 | ws['B' + str(current_row_number)].alignment = c_c_alignment |
|
| 370 | ws['B' + str(current_row_number)] = reporting_period_data['names'][i] |
|
| 371 | ws['B' + str(current_row_number)].border = f_border |
|
| 372 | ||
| 373 | ws['C' + str(current_row_number)].font = title_font |
|
| 374 | ws['C' + str(current_row_number)].alignment = c_c_alignment |
|
| 375 | ws['C' + str(current_row_number)].border = f_border |
|
| 376 | ws['C' + str(current_row_number)] = round(reporting_period_data['subtotals'][i], 2) |
|
| 377 | ||
| 378 | current_row_number += 1 |
|
| 379 | ||
| 380 | table_end_row_number = current_row_number - 1 |
|
| 381 | ||
| 382 | pie = PieChart() |
|
| 383 | labels = Reference(ws, min_col=2, min_row=table_start_row_number + 1, max_row=table_end_row_number) |
|
| 384 | pie_data = Reference(ws, min_col=3, min_row=table_start_row_number, max_row=table_end_row_number) |
|
| 385 | pie.add_data(pie_data, titles_from_data=True) |
|
| 386 | pie.set_categories(labels) |
|
| 387 | pie.height = 5.25 |
|
| 388 | pie.width = 9 |
|
| 389 | s1 = pie.series[0] |
|
| 390 | s1.dLbls = DataLabelList() |
|
| 391 | s1.dLbls.showCatName = False |
|
| 392 | s1.dLbls.showVal = True |
|
| 393 | s1.dLbls.showPercent = True |
|
| 394 | table_cell = 'D' + str(table_start_row_number) |
|
| 395 | ws.add_chart(pie, table_cell) |
|
| 396 | ||
| 397 | if ca_len < 4: |
|
| 398 | current_row_number = current_row_number - ca_len + 4 |
|
| 399 | ||
| 400 | else: |
|
| 401 | for i in range(21, 29 + 1): |
|
| 402 | current_row_number = 30 |
|
| 403 | ws.row_dimensions[i].height = 0.1 |
|
| 404 | ||
| 405 | ############################################### |
|
| 406 | ||
| @@ 371-429 (lines=59) @@ | ||
| 368 | len(reporting_period_data['subtotals_in_kgce']) == 0: |
|
| 369 | has_kgce_data_flag = False |
|
| 370 | ||
| 371 | if has_kgce_data_flag: |
|
| 372 | ws['B' + str(current_row_number)].font = title_font |
|
| 373 | ws['B' + str(current_row_number)] = name + ' 吨标准煤 (TCE) 占比' |
|
| 374 | ||
| 375 | current_row_number += 1 |
|
| 376 | table_start_row_number = current_row_number |
|
| 377 | ||
| 378 | ws['B' + str(current_row_number)].fill = table_fill |
|
| 379 | ws['B' + str(current_row_number)].font = name_font |
|
| 380 | ws['B' + str(current_row_number)].alignment = c_c_alignment |
|
| 381 | ws['B' + str(current_row_number)].border = f_border |
|
| 382 | ||
| 383 | ws['C' + str(current_row_number)].fill = table_fill |
|
| 384 | ws['C' + str(current_row_number)].font = name_font |
|
| 385 | ws['C' + str(current_row_number)].alignment = c_c_alignment |
|
| 386 | ws['C' + str(current_row_number)].border = f_border |
|
| 387 | ws['C' + str(current_row_number)] = '吨标准煤 (TCE) 占比' |
|
| 388 | ||
| 389 | current_row_number += 1 |
|
| 390 | ||
| 391 | ca_len = len(reporting_period_data['names']) |
|
| 392 | ||
| 393 | for i in range(0, ca_len): |
|
| 394 | ws['B' + str(current_row_number)].font = title_font |
|
| 395 | ws['B' + str(current_row_number)].alignment = c_c_alignment |
|
| 396 | ws['B' + str(current_row_number)] = reporting_period_data['names'][i] |
|
| 397 | ws['B' + str(current_row_number)].border = f_border |
|
| 398 | ||
| 399 | ws['C' + str(current_row_number)].font = title_font |
|
| 400 | ws['C' + str(current_row_number)].alignment = c_c_alignment |
|
| 401 | ws['C' + str(current_row_number)].border = f_border |
|
| 402 | ws['C' + str(current_row_number)] = round(reporting_period_data['subtotals_in_kgce'][i], 3) |
|
| 403 | ||
| 404 | current_row_number += 1 |
|
| 405 | ||
| 406 | table_end_row_number = current_row_number - 1 |
|
| 407 | ||
| 408 | pie = PieChart() |
|
| 409 | labels = Reference(ws, min_col=2, min_row=table_start_row_number+1, max_row=table_end_row_number) |
|
| 410 | pie_data = Reference(ws, min_col=3, min_row=table_start_row_number, max_row=table_end_row_number) |
|
| 411 | pie.add_data(pie_data, titles_from_data=True) |
|
| 412 | pie.set_categories(labels) |
|
| 413 | pie.height = 5.25 |
|
| 414 | pie.width = 9 |
|
| 415 | s1 = pie.series[0] |
|
| 416 | s1.dLbls = DataLabelList() |
|
| 417 | s1.dLbls.showCatName = False |
|
| 418 | s1.dLbls.showVal = True |
|
| 419 | s1.dLbls.showPercent = True |
|
| 420 | table_cell = 'D' + str(table_start_row_number) |
|
| 421 | ws.add_chart(pie, table_cell) |
|
| 422 | ||
| 423 | if ca_len < 4: |
|
| 424 | current_row_number = current_row_number - ca_len + 4 |
|
| 425 | ||
| 426 | else: |
|
| 427 | for i in range(21, 29 + 1): |
|
| 428 | current_row_number = 30 |
|
| 429 | ws.row_dimensions[i].height = 0.1 |
|
| 430 | ||
| 431 | ##################################################### |
|
| 432 | ||
| @@ 441-498 (lines=58) @@ | ||
| 438 | len(reporting_period_data['subtotals_in_kgco2e']) == 0: |
|
| 439 | has_kgco2e_data_flag = False |
|
| 440 | ||
| 441 | if has_kgco2e_data_flag: |
|
| 442 | ws['B' + str(current_row_number)].font = title_font |
|
| 443 | ws['B' + str(current_row_number)] = name + ' 吨二氧化碳排放 (TCO2E) 占比' |
|
| 444 | ||
| 445 | current_row_number += 1 |
|
| 446 | table_start_row_number = current_row_number |
|
| 447 | ||
| 448 | ws['B' + str(current_row_number)].fill = table_fill |
|
| 449 | ws['B' + str(current_row_number)].font = name_font |
|
| 450 | ws['B' + str(current_row_number)].alignment = c_c_alignment |
|
| 451 | ws['B' + str(current_row_number)].border = f_border |
|
| 452 | ||
| 453 | ws['C' + str(current_row_number)].fill = table_fill |
|
| 454 | ws['C' + str(current_row_number)].font = name_font |
|
| 455 | ws['C' + str(current_row_number)].alignment = c_c_alignment |
|
| 456 | ws['C' + str(current_row_number)].border = f_border |
|
| 457 | ws['C' + str(current_row_number)] = '吨二氧化碳排放 (TCO2E) 占比' |
|
| 458 | ||
| 459 | current_row_number += 1 |
|
| 460 | ||
| 461 | ca_len = len(reporting_period_data['names']) |
|
| 462 | ||
| 463 | for i in range(0, ca_len): |
|
| 464 | ws['B' + str(current_row_number)].font = title_font |
|
| 465 | ws['B' + str(current_row_number)].alignment = c_c_alignment |
|
| 466 | ws['B' + str(current_row_number)] = reporting_period_data['names'][i] |
|
| 467 | ws['B' + str(current_row_number)].border = f_border |
|
| 468 | ||
| 469 | ws['C' + str(current_row_number)].font = title_font |
|
| 470 | ws['C' + str(current_row_number)].alignment = c_c_alignment |
|
| 471 | ws['C' + str(current_row_number)].border = f_border |
|
| 472 | ws['C' + str(current_row_number)] = round(reporting_period_data['subtotals_in_kgco2e'][i], 3) |
|
| 473 | current_row_number += 1 |
|
| 474 | ||
| 475 | table_end_row_number = current_row_number - 1 |
|
| 476 | ||
| 477 | pie = PieChart() |
|
| 478 | labels = Reference(ws, min_col=2, min_row=table_start_row_number + 1, max_row=table_end_row_number) |
|
| 479 | pie_data = Reference(ws, min_col=3, min_row=table_start_row_number, max_row=table_end_row_number) |
|
| 480 | pie.add_data(pie_data, titles_from_data=True) |
|
| 481 | pie.set_categories(labels) |
|
| 482 | pie.height = 5.25 |
|
| 483 | pie.width = 9 |
|
| 484 | s1 = pie.series[0] |
|
| 485 | s1.dLbls = DataLabelList() |
|
| 486 | s1.dLbls.showCatName = False |
|
| 487 | s1.dLbls.showVal = True |
|
| 488 | s1.dLbls.showPercent = True |
|
| 489 | table_cell = 'D' + str(table_start_row_number) |
|
| 490 | ws.add_chart(pie, table_cell) |
|
| 491 | ||
| 492 | if ca_len < 4: |
|
| 493 | current_row_number = current_row_number - ca_len + 4 |
|
| 494 | ||
| 495 | else: |
|
| 496 | for i in range(30, 39 + 1): |
|
| 497 | current_row_number = 40 |
|
| 498 | ws.row_dimensions[i].height = 0.1 |
|
| 499 | ||
| 500 | ############################################### |
|
| 501 | current_row_number += 1 |
|