| @@ 354-414 (lines=61) @@ | ||
| 351 | len(reporting_period_data['subtotals']) == 0: |
|
| 352 | has_subtotals_data_flag = False |
|
| 353 | ||
| 354 | if has_subtotals_data_flag: |
|
| 355 | ws['B' + str(current_row_number)].font = title_font |
|
| 356 | ws['B' + str(current_row_number)] = name + ' 成本占比' |
|
| 357 | ||
| 358 | current_row_number += 1 |
|
| 359 | ||
| 360 | table_start_row_number = current_row_number |
|
| 361 | ||
| 362 | ws['B' + str(current_row_number)].fill = table_fill |
|
| 363 | ws['B' + str(current_row_number)].font = name_font |
|
| 364 | ws['B' + str(current_row_number)].alignment = c_c_alignment |
|
| 365 | ws['B' + str(current_row_number)].border = f_border |
|
| 366 | ||
| 367 | ws['C' + str(current_row_number)].fill = table_fill |
|
| 368 | ws['C' + str(current_row_number)].font = name_font |
|
| 369 | ws['C' + str(current_row_number)].alignment = c_c_alignment |
|
| 370 | ws['C' + str(current_row_number)].border = f_border |
|
| 371 | ws['C' + str(current_row_number)] = '成本占比' |
|
| 372 | ||
| 373 | current_row_number += 1 |
|
| 374 | ||
| 375 | ca_len = len(reporting_period_data['names']) |
|
| 376 | ||
| 377 | for i in range(0, ca_len): |
|
| 378 | ws['B' + str(current_row_number)].font = title_font |
|
| 379 | ws['B' + str(current_row_number)].alignment = c_c_alignment |
|
| 380 | ws['B' + str(current_row_number)] = reporting_period_data['names'][i] |
|
| 381 | ws['B' + str(current_row_number)].border = f_border |
|
| 382 | ||
| 383 | ws['C' + str(current_row_number)].font = title_font |
|
| 384 | ws['C' + str(current_row_number)].alignment = c_c_alignment |
|
| 385 | ws['C' + str(current_row_number)].border = f_border |
|
| 386 | ws['C' + str(current_row_number)] = round(reporting_period_data['subtotals'][i], 2) |
|
| 387 | ||
| 388 | current_row_number += 1 |
|
| 389 | ||
| 390 | table_end_row_number = current_row_number - 1 |
|
| 391 | ||
| 392 | pie = PieChart() |
|
| 393 | pie.title = name + ' 成本占比' |
|
| 394 | labels = Reference(ws, min_col=2, min_row=table_start_row_number + 1, max_row=table_end_row_number) |
|
| 395 | pie_data = Reference(ws, min_col=3, min_row=table_start_row_number, max_row=table_end_row_number) |
|
| 396 | pie.add_data(pie_data, titles_from_data=True) |
|
| 397 | pie.set_categories(labels) |
|
| 398 | pie.height = 6.6 |
|
| 399 | pie.width = 9 |
|
| 400 | s1 = pie.series[0] |
|
| 401 | s1.dLbls = DataLabelList() |
|
| 402 | s1.dLbls.showCatName = False |
|
| 403 | s1.dLbls.showVal = True |
|
| 404 | s1.dLbls.showPercent = True |
|
| 405 | table_cell = 'D' + str(table_start_row_number) |
|
| 406 | ws.add_chart(pie, table_cell) |
|
| 407 | ||
| 408 | if ca_len < 4: |
|
| 409 | current_row_number = current_row_number - ca_len + 4 |
|
| 410 | ||
| 411 | else: |
|
| 412 | for i in range(21, 29 + 1): |
|
| 413 | current_row_number = 30 |
|
| 414 | ws.row_dimensions[i].height = 0.1 |
|
| 415 | ||
| 416 | ############################################### |
|
| 417 | ||
| @@ 345-404 (lines=60) @@ | ||
| 342 | len(reporting_period_data['subtotals']) == 0: |
|
| 343 | has_subtotals_data_flag = False |
|
| 344 | ||
| 345 | if has_subtotals_data_flag: |
|
| 346 | ws['B' + str(current_row_number)].font = title_font |
|
| 347 | ws['B' + str(current_row_number)] = name + ' 成本占比' |
|
| 348 | ||
| 349 | current_row_number += 1 |
|
| 350 | ||
| 351 | table_start_row_number = current_row_number |
|
| 352 | ||
| 353 | ws['B' + str(current_row_number)].fill = table_fill |
|
| 354 | ws['B' + str(current_row_number)].font = name_font |
|
| 355 | ws['B' + str(current_row_number)].alignment = c_c_alignment |
|
| 356 | ws['B' + str(current_row_number)].border = f_border |
|
| 357 | ||
| 358 | ws['C' + str(current_row_number)].fill = table_fill |
|
| 359 | ws['C' + str(current_row_number)].font = name_font |
|
| 360 | ws['C' + str(current_row_number)].alignment = c_c_alignment |
|
| 361 | ws['C' + str(current_row_number)].border = f_border |
|
| 362 | ws['C' + str(current_row_number)] = '成本占比' |
|
| 363 | ||
| 364 | current_row_number += 1 |
|
| 365 | ||
| 366 | ca_len = len(reporting_period_data['names']) |
|
| 367 | ||
| 368 | for i in range(0, ca_len): |
|
| 369 | ws['B' + str(current_row_number)].font = title_font |
|
| 370 | ws['B' + str(current_row_number)].alignment = c_c_alignment |
|
| 371 | ws['B' + str(current_row_number)] = reporting_period_data['names'][i] |
|
| 372 | ws['B' + str(current_row_number)].border = f_border |
|
| 373 | ||
| 374 | ws['C' + str(current_row_number)].font = title_font |
|
| 375 | ws['C' + str(current_row_number)].alignment = c_c_alignment |
|
| 376 | ws['C' + str(current_row_number)].border = f_border |
|
| 377 | ws['C' + str(current_row_number)] = round(reporting_period_data['subtotals'][i], 2) |
|
| 378 | ||
| 379 | current_row_number += 1 |
|
| 380 | ||
| 381 | table_end_row_number = current_row_number - 1 |
|
| 382 | ||
| 383 | pie = PieChart() |
|
| 384 | labels = Reference(ws, min_col=2, min_row=table_start_row_number + 1, max_row=table_end_row_number) |
|
| 385 | pie_data = Reference(ws, min_col=3, min_row=table_start_row_number, max_row=table_end_row_number) |
|
| 386 | pie.add_data(pie_data, titles_from_data=True) |
|
| 387 | pie.set_categories(labels) |
|
| 388 | pie.height = 5.25 |
|
| 389 | pie.width = 8 |
|
| 390 | s1 = pie.series[0] |
|
| 391 | s1.dLbls = DataLabelList() |
|
| 392 | s1.dLbls.showCatName = False |
|
| 393 | s1.dLbls.showVal = True |
|
| 394 | s1.dLbls.showPercent = True |
|
| 395 | table_cell = 'D' + str(table_start_row_number) |
|
| 396 | ws.add_chart(pie, table_cell) |
|
| 397 | ||
| 398 | if ca_len < 4: |
|
| 399 | current_row_number = current_row_number - ca_len + 4 |
|
| 400 | ||
| 401 | else: |
|
| 402 | for i in range(21, 29 + 1): |
|
| 403 | current_row_number = 30 |
|
| 404 | ws.row_dimensions[i].height = 0.1 |
|
| 405 | ||
| 406 | ############################################### |
|
| 407 | ||