| @@ 283-569 (lines=287) @@ | ||
| 280 | #################################################################################################################### |
|
| 281 | table_start_draw_flag = current_row_number + 1 |
|
| 282 | ||
| 283 | if 'values' not in reporting_period_data.keys() or \ |
|
| 284 | reporting_period_data['values'] is None or \ |
|
| 285 | len(reporting_period_data['values']) == 0 or \ |
|
| 286 | 'timestamps' not in reporting_period_data.keys() or \ |
|
| 287 | reporting_period_data['timestamps'] is None or \ |
|
| 288 | len(reporting_period_data['timestamps']) == 0 or \ |
|
| 289 | len(reporting_period_data['timestamps'][0]) == 0: |
|
| 290 | pass |
|
| 291 | else: |
|
| 292 | ||
| 293 | if not is_base_period_timestamp_exists_flag: |
|
| 294 | reporting_period_data = report['reporting_period'] |
|
| 295 | times = reporting_period_data['timestamps'] |
|
| 296 | ca_len = len(report['reporting_period']['names']) |
|
| 297 | real_timestamps_len = timestamps_data_not_equal_0(report['parameters']['timestamps']) |
|
| 298 | ws['B' + str(current_row_number)].font = title_font |
|
| 299 | ws['B' + str(current_row_number)] = name + ' ' + _('Detailed Data') |
|
| 300 | ||
| 301 | current_row_number += 1 |
|
| 302 | # 1: Stand for blank line 2: Stand for title |
|
| 303 | current_row_number += ca_len * 6 + real_timestamps_len * 6 + 1 + 2 |
|
| 304 | table_start_row_number = current_row_number |
|
| 305 | ||
| 306 | time = times[0] |
|
| 307 | has_data = False |
|
| 308 | ||
| 309 | if len(time) > 0: |
|
| 310 | has_data = True |
|
| 311 | ||
| 312 | if has_data: |
|
| 313 | ||
| 314 | ws.row_dimensions[current_row_number].height = 60 |
|
| 315 | current_col_number = 2 |
|
| 316 | col = format_cell.get_column_letter(current_col_number) |
|
| 317 | ws[col + str(current_row_number)].fill = table_fill |
|
| 318 | ws[col + str(current_row_number)].font = title_font |
|
| 319 | ws[col + str(current_row_number)].border = f_border |
|
| 320 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 321 | ws[col + str(current_row_number)] = _('Datetime') |
|
| 322 | ||
| 323 | for i in range(0, ca_len): |
|
| 324 | current_col_number += 1 |
|
| 325 | col = format_cell.get_column_letter(current_col_number) |
|
| 326 | ||
| 327 | ws[col + str(current_row_number)].fill = table_fill |
|
| 328 | ws[col + str(current_row_number)].font = title_font |
|
| 329 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 330 | ws[col + str(current_row_number)] = reporting_period_data['names'][i] + \ |
|
| 331 | " (" + reporting_period_data['units'][i] + ")" |
|
| 332 | ws[col + str(current_row_number)].border = f_border |
|
| 333 | ||
| 334 | current_row_number += 1 |
|
| 335 | ||
| 336 | for i in range(0, len(time)): |
|
| 337 | current_col_number = 2 |
|
| 338 | col = format_cell.get_column_letter(current_col_number) |
|
| 339 | ws[col + str(current_row_number)].font = title_font |
|
| 340 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 341 | ws[col + str(current_row_number)] = time[i] |
|
| 342 | ws[col + str(current_row_number)].border = f_border |
|
| 343 | ||
| 344 | for j in range(0, ca_len): |
|
| 345 | current_col_number += 1 |
|
| 346 | col = format_cell.get_column_letter(current_col_number) |
|
| 347 | ||
| 348 | ws[col + str(current_row_number)].font = title_font |
|
| 349 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 350 | ws[col + str(current_row_number)] = round(reporting_period_data['values'][j][i], 2) |
|
| 351 | ws[col + str(current_row_number)].border = f_border |
|
| 352 | ||
| 353 | current_row_number += 1 |
|
| 354 | ||
| 355 | table_end_row_number = current_row_number - 1 |
|
| 356 | ||
| 357 | current_col_number = 2 |
|
| 358 | col = format_cell.get_column_letter(current_col_number) |
|
| 359 | ws[col + str(current_row_number)].font = title_font |
|
| 360 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 361 | ws[col + str(current_row_number)] = _('Subtotal') |
|
| 362 | ws[col + str(current_row_number)].border = f_border |
|
| 363 | ||
| 364 | for i in range(0, ca_len): |
|
| 365 | current_col_number += 1 |
|
| 366 | col = format_cell.get_column_letter(current_col_number) |
|
| 367 | ||
| 368 | ws[col + str(current_row_number)].font = title_font |
|
| 369 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 370 | ws[col + str(current_row_number)] = round(reporting_period_data['subtotals'][i], 2) |
|
| 371 | ws[col + str(current_row_number)].border = f_border |
|
| 372 | ||
| 373 | # line |
|
| 374 | line = LineChart() |
|
| 375 | line.title = _('Reporting Period Output') + ' - ' \ |
|
| 376 | + reporting_period_data['names'][i] + " (" + reporting_period_data['units'][i] + ")" |
|
| 377 | labels = Reference(ws, min_col=2, min_row=table_start_row_number + 1, max_row=table_end_row_number) |
|
| 378 | line_data = Reference(ws, min_col=3 + i, min_row=table_start_row_number, |
|
| 379 | max_row=table_end_row_number) |
|
| 380 | line.add_data(line_data, titles_from_data=True) |
|
| 381 | line.set_categories(labels) |
|
| 382 | line_data = line.series[0] |
|
| 383 | line_data.marker.symbol = "circle" |
|
| 384 | line_data.smooth = True |
|
| 385 | line.x_axis.crosses = 'min' |
|
| 386 | line.height = 8.25 |
|
| 387 | line.width = 24 |
|
| 388 | line.dLbls = DataLabelList() |
|
| 389 | line.dLbls.dLblPos = 't' |
|
| 390 | line.dLbls.showVal = True |
|
| 391 | line.dLbls.showPercent = False |
|
| 392 | chart_col = 'B' |
|
| 393 | chart_cell = chart_col + str(table_start_draw_flag + 6 * i) |
|
| 394 | ws.add_chart(line, chart_cell) |
|
| 395 | ||
| 396 | current_row_number += 2 |
|
| 397 | else: |
|
| 398 | base_period_data = report['base_period'] |
|
| 399 | reporting_period_data = report['reporting_period'] |
|
| 400 | base_period_timestamps = base_period_data['timestamps'] |
|
| 401 | reporting_period_timestamps = reporting_period_data['timestamps'] |
|
| 402 | # Tip: |
|
| 403 | # base_period_data['names'] == reporting_period_data['names'] |
|
| 404 | # base_period_data['units'] == reporting_period_data['units'] |
|
| 405 | base_period_data_ca_len = len(base_period_data['names']) |
|
| 406 | reporting_period_data_ca_len = len(reporting_period_data['names']) |
|
| 407 | real_timestamps_len = timestamps_data_not_equal_0(report['parameters']['timestamps']) |
|
| 408 | ws['B' + str(current_row_number)].font = title_font |
|
| 409 | ws['B' + str(current_row_number)] = name + ' ' + _('Detailed Data') |
|
| 410 | ||
| 411 | current_row_number += 1 |
|
| 412 | # 1: Stand for blank line 2: Stand for title |
|
| 413 | current_row_number += reporting_period_data_ca_len * 6 + real_timestamps_len * 6 + 1 + 2 |
|
| 414 | table_start_row_number = current_row_number |
|
| 415 | ||
| 416 | has_data = False |
|
| 417 | ||
| 418 | if len(base_period_timestamps[0]) or len(reporting_period_timestamps[0]) > 0: |
|
| 419 | has_data = True |
|
| 420 | ||
| 421 | if has_data: |
|
| 422 | ws.row_dimensions[current_row_number].height = 60 |
|
| 423 | current_col_number = 2 |
|
| 424 | col = format_cell.get_column_letter(current_col_number) |
|
| 425 | ws[col + str(current_row_number)].fill = table_fill |
|
| 426 | ws[col + str(current_row_number)].font = title_font |
|
| 427 | ws[col + str(current_row_number)].border = f_border |
|
| 428 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 429 | ws[col + str(current_row_number)] = _('Base Period') + " - " + _('Datetime') |
|
| 430 | ||
| 431 | for i in range(0, base_period_data_ca_len): |
|
| 432 | current_col_number += 1 |
|
| 433 | col = format_cell.get_column_letter(current_col_number) |
|
| 434 | ||
| 435 | ws[col + str(current_row_number)].fill = table_fill |
|
| 436 | ws[col + str(current_row_number)].font = title_font |
|
| 437 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 438 | ws[col + str(current_row_number)] = _('Base Period') + " - " + base_period_data['names'][i] + \ |
|
| 439 | " (" + base_period_data['units'][i] + ")" |
|
| 440 | ws[col + str(current_row_number)].border = f_border |
|
| 441 | current_col_number += 1 |
|
| 442 | col = format_cell.get_column_letter(current_col_number) |
|
| 443 | ||
| 444 | ws[col + str(current_row_number)].fill = table_fill |
|
| 445 | ws[col + str(current_row_number)].font = title_font |
|
| 446 | ws[col + str(current_row_number)].border = f_border |
|
| 447 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 448 | ws[col + str(current_row_number)] = _('Reporting Period') + " - " + _('Datetime') |
|
| 449 | ||
| 450 | for i in range(0, reporting_period_data_ca_len): |
|
| 451 | current_col_number += 1 |
|
| 452 | col = format_cell.get_column_letter(current_col_number) |
|
| 453 | ws[col + str(current_row_number)].fill = table_fill |
|
| 454 | ws[col + str(current_row_number)].font = title_font |
|
| 455 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 456 | ws[col + str(current_row_number)] = _('Reporting Period') + " - " \ |
|
| 457 | + reporting_period_data['names'][i] + " (" + \ |
|
| 458 | reporting_period_data['units'][i] + ")" |
|
| 459 | ws[col + str(current_row_number)].border = f_border |
|
| 460 | ||
| 461 | current_row_number += 1 |
|
| 462 | ||
| 463 | max_timestamps_len = len(base_period_timestamps[0]) \ |
|
| 464 | if len(base_period_timestamps[0]) >= len(reporting_period_timestamps[0]) \ |
|
| 465 | else len(reporting_period_timestamps[0]) |
|
| 466 | ||
| 467 | for i in range(0, max_timestamps_len): |
|
| 468 | current_col_number = 2 |
|
| 469 | col = format_cell.get_column_letter(current_col_number) |
|
| 470 | ws[col + str(current_row_number)].font = title_font |
|
| 471 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 472 | ws[col + str(current_row_number)] = base_period_timestamps[0][i] \ |
|
| 473 | if i < len(base_period_timestamps[0]) else None |
|
| 474 | ws[col + str(current_row_number)].border = f_border |
|
| 475 | ||
| 476 | for j in range(0, base_period_data_ca_len): |
|
| 477 | current_col_number += 1 |
|
| 478 | col = format_cell.get_column_letter(current_col_number) |
|
| 479 | ||
| 480 | ws[col + str(current_row_number)].font = title_font |
|
| 481 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 482 | ws[col + str(current_row_number)] = round(base_period_data['values'][j][i], 2) \ |
|
| 483 | if i < len(base_period_data['values'][j]) else None |
|
| 484 | ws[col + str(current_row_number)].border = f_border |
|
| 485 | current_col_number += 1 |
|
| 486 | col = format_cell.get_column_letter(current_col_number) |
|
| 487 | ||
| 488 | ws[col + str(current_row_number)].font = title_font |
|
| 489 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 490 | ws[col + str(current_row_number)] = reporting_period_timestamps[0][i] \ |
|
| 491 | if i < len(reporting_period_timestamps[0]) else None |
|
| 492 | ws[col + str(current_row_number)].border = f_border |
|
| 493 | ||
| 494 | for j in range(0, reporting_period_data_ca_len): |
|
| 495 | current_col_number += 1 |
|
| 496 | col = format_cell.get_column_letter(current_col_number) |
|
| 497 | ||
| 498 | ws[col + str(current_row_number)].font = title_font |
|
| 499 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 500 | ws[col + str(current_row_number)] = round(reporting_period_data['values'][j][i], 2) \ |
|
| 501 | if i < len(reporting_period_data['values'][j]) else None |
|
| 502 | ws[col + str(current_row_number)].border = f_border |
|
| 503 | ||
| 504 | current_row_number += 1 |
|
| 505 | ||
| 506 | current_col_number = 2 |
|
| 507 | col = format_cell.get_column_letter(current_col_number) |
|
| 508 | ws[col + str(current_row_number)].font = title_font |
|
| 509 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 510 | ws[col + str(current_row_number)] = _('Subtotal') |
|
| 511 | ws[col + str(current_row_number)].border = f_border |
|
| 512 | ||
| 513 | for i in range(0, base_period_data_ca_len): |
|
| 514 | current_col_number += 1 |
|
| 515 | col = format_cell.get_column_letter(current_col_number) |
|
| 516 | ws[col + str(current_row_number)].font = title_font |
|
| 517 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 518 | ws[col + str(current_row_number)] = round(base_period_data['subtotals'][i], 2) |
|
| 519 | ws[col + str(current_row_number)].border = f_border |
|
| 520 | ||
| 521 | current_col_number += 1 |
|
| 522 | col = format_cell.get_column_letter(current_col_number) |
|
| 523 | ||
| 524 | ws[col + str(current_row_number)].font = title_font |
|
| 525 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 526 | ws[col + str(current_row_number)] = _('Subtotal') |
|
| 527 | ws[col + str(current_row_number)].border = f_border |
|
| 528 | ||
| 529 | for i in range(0, reporting_period_data_ca_len): |
|
| 530 | current_col_number += 1 |
|
| 531 | col = format_cell.get_column_letter(current_col_number) |
|
| 532 | ws[col + str(current_row_number)].font = title_font |
|
| 533 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 534 | ws[col + str(current_row_number)] = round(reporting_period_data['subtotals'][i], 2) |
|
| 535 | ws[col + str(current_row_number)].border = f_border |
|
| 536 | ||
| 537 | for i in range(0, reporting_period_data_ca_len): |
|
| 538 | # line |
|
| 539 | line = LineChart() |
|
| 540 | line.title = _('Base Period Output') + ' / ' \ |
|
| 541 | + _('Reporting Period Output') + ' - ' \ |
|
| 542 | + reporting_period_data['names'][i] + " (" + reporting_period_data['units'][i] + ")" |
|
| 543 | labels = Reference(ws, min_col=2 + base_period_data_ca_len + 1, |
|
| 544 | min_row=table_start_row_number + 1, |
|
| 545 | max_row=table_start_row_number + len(reporting_period_timestamps[0])) |
|
| 546 | base_line_data = Reference(ws, min_col=3 + i, min_row=table_start_row_number, |
|
| 547 | max_row=table_start_row_number + len(reporting_period_timestamps[0])) |
|
| 548 | reporting_line_data = Reference(ws, min_col=3 + base_period_data_ca_len + 1 + i, |
|
| 549 | min_row=table_start_row_number, |
|
| 550 | max_row=table_start_row_number |
|
| 551 | + len(reporting_period_timestamps[0])) |
|
| 552 | line.add_data(base_line_data, titles_from_data=True) |
|
| 553 | line.add_data(reporting_line_data, titles_from_data=True) |
|
| 554 | line.set_categories(labels) |
|
| 555 | for j in range(len(line.series)): |
|
| 556 | line.series[j].marker.symbol = "circle" |
|
| 557 | line.series[j].smooth = True |
|
| 558 | line.x_axis.crosses = 'min' |
|
| 559 | line.height = 8.25 |
|
| 560 | line.width = 24 |
|
| 561 | line.dLbls = DataLabelList() |
|
| 562 | line.dLbls.dLblPos = 't' |
|
| 563 | line.dLbls.showVal = True |
|
| 564 | line.dLbls.showPercent = False |
|
| 565 | chart_col = 'B' |
|
| 566 | chart_cell = chart_col + str(table_start_draw_flag + 6 * i) |
|
| 567 | ws.add_chart(line, chart_cell) |
|
| 568 | ||
| 569 | current_row_number += 2 |
|
| 570 | ||
| 571 | #################################################################################################################### |
|
| 572 | if "child_space" not in report.keys() or "energy_category_names" not in report['child_space'].keys() or \ |
|
| @@ 261-547 (lines=287) @@ | ||
| 258 | #################################################################################################################### |
|
| 259 | table_start_draw_flag = current_row_number + 1 |
|
| 260 | ||
| 261 | if 'values' not in reporting_period_data.keys() or \ |
|
| 262 | reporting_period_data['values'] is None or \ |
|
| 263 | len(reporting_period_data['values']) == 0 or \ |
|
| 264 | 'timestamps' not in reporting_period_data.keys() or \ |
|
| 265 | reporting_period_data['timestamps'] is None or \ |
|
| 266 | len(reporting_period_data['timestamps']) == 0 or \ |
|
| 267 | len(reporting_period_data['timestamps'][0]) == 0: |
|
| 268 | pass |
|
| 269 | else: |
|
| 270 | ||
| 271 | if not is_base_period_timestamp_exists_flag: |
|
| 272 | reporting_period_data = report['reporting_period'] |
|
| 273 | times = reporting_period_data['timestamps'] |
|
| 274 | ca_len = len(report['reporting_period']['names']) |
|
| 275 | real_timestamps_len = timestamps_data_not_equal_0(report['parameters']['timestamps']) |
|
| 276 | ws['B' + str(current_row_number)].font = title_font |
|
| 277 | ws['B' + str(current_row_number)] = name + ' ' + _('Detailed Data') |
|
| 278 | ||
| 279 | current_row_number += 1 |
|
| 280 | # 1: Stand for blank line 2: Stand for title |
|
| 281 | current_row_number += ca_len * 6 + real_timestamps_len * 6 + 1 + 2 |
|
| 282 | table_start_row_number = current_row_number |
|
| 283 | ||
| 284 | time = times[0] |
|
| 285 | has_data = False |
|
| 286 | ||
| 287 | if len(time) > 0: |
|
| 288 | has_data = True |
|
| 289 | ||
| 290 | if has_data: |
|
| 291 | ||
| 292 | ws.row_dimensions[current_row_number].height = 60 |
|
| 293 | current_col_number = 2 |
|
| 294 | col = format_cell.get_column_letter(current_col_number) |
|
| 295 | ws[col + str(current_row_number)].fill = table_fill |
|
| 296 | ws[col + str(current_row_number)].font = title_font |
|
| 297 | ws[col + str(current_row_number)].border = f_border |
|
| 298 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 299 | ws[col + str(current_row_number)] = _('Datetime') |
|
| 300 | ||
| 301 | for i in range(0, ca_len): |
|
| 302 | current_col_number += 1 |
|
| 303 | col = format_cell.get_column_letter(current_col_number) |
|
| 304 | ||
| 305 | ws[col + str(current_row_number)].fill = table_fill |
|
| 306 | ws[col + str(current_row_number)].font = title_font |
|
| 307 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 308 | ws[col + str(current_row_number)] = reporting_period_data['names'][i] + \ |
|
| 309 | " (" + reporting_period_data['units'][i] + ")" |
|
| 310 | ws[col + str(current_row_number)].border = f_border |
|
| 311 | ||
| 312 | current_row_number += 1 |
|
| 313 | ||
| 314 | for i in range(0, len(time)): |
|
| 315 | current_col_number = 2 |
|
| 316 | col = format_cell.get_column_letter(current_col_number) |
|
| 317 | ws[col + str(current_row_number)].font = title_font |
|
| 318 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 319 | ws[col + str(current_row_number)] = time[i] |
|
| 320 | ws[col + str(current_row_number)].border = f_border |
|
| 321 | ||
| 322 | for j in range(0, ca_len): |
|
| 323 | current_col_number += 1 |
|
| 324 | col = format_cell.get_column_letter(current_col_number) |
|
| 325 | ||
| 326 | ws[col + str(current_row_number)].font = title_font |
|
| 327 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 328 | ws[col + str(current_row_number)] = round(reporting_period_data['values'][j][i], 2) |
|
| 329 | ws[col + str(current_row_number)].border = f_border |
|
| 330 | ||
| 331 | current_row_number += 1 |
|
| 332 | ||
| 333 | table_end_row_number = current_row_number - 1 |
|
| 334 | ||
| 335 | current_col_number = 2 |
|
| 336 | col = format_cell.get_column_letter(current_col_number) |
|
| 337 | ws[col + str(current_row_number)].font = title_font |
|
| 338 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 339 | ws[col + str(current_row_number)] = _('Subtotal') |
|
| 340 | ws[col + str(current_row_number)].border = f_border |
|
| 341 | ||
| 342 | for i in range(0, ca_len): |
|
| 343 | current_col_number += 1 |
|
| 344 | col = format_cell.get_column_letter(current_col_number) |
|
| 345 | ||
| 346 | ws[col + str(current_row_number)].font = title_font |
|
| 347 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 348 | ws[col + str(current_row_number)] = round(reporting_period_data['subtotals'][i], 2) |
|
| 349 | ws[col + str(current_row_number)].border = f_border |
|
| 350 | ||
| 351 | # line |
|
| 352 | line = LineChart() |
|
| 353 | line.title = _('Reporting Period Output') + ' - ' \ |
|
| 354 | + reporting_period_data['names'][i] + " (" + reporting_period_data['units'][i] + ")" |
|
| 355 | labels = Reference(ws, min_col=2, min_row=table_start_row_number + 1, max_row=table_end_row_number) |
|
| 356 | line_data = Reference(ws, min_col=3 + i, min_row=table_start_row_number, |
|
| 357 | max_row=table_end_row_number) |
|
| 358 | line.add_data(line_data, titles_from_data=True) |
|
| 359 | line.set_categories(labels) |
|
| 360 | line_data = line.series[0] |
|
| 361 | line_data.marker.symbol = "circle" |
|
| 362 | line_data.smooth = True |
|
| 363 | line.x_axis.crosses = 'min' |
|
| 364 | line.height = 8.25 |
|
| 365 | line.width = 24 |
|
| 366 | line.dLbls = DataLabelList() |
|
| 367 | line.dLbls.dLblPos = 't' |
|
| 368 | line.dLbls.showVal = True |
|
| 369 | line.dLbls.showPercent = False |
|
| 370 | chart_col = 'B' |
|
| 371 | chart_cell = chart_col + str(table_start_draw_flag + 6 * i) |
|
| 372 | ws.add_chart(line, chart_cell) |
|
| 373 | ||
| 374 | current_row_number += 2 |
|
| 375 | else: |
|
| 376 | base_period_data = report['base_period'] |
|
| 377 | reporting_period_data = report['reporting_period'] |
|
| 378 | base_period_timestamps = base_period_data['timestamps'] |
|
| 379 | reporting_period_timestamps = reporting_period_data['timestamps'] |
|
| 380 | # Tip: |
|
| 381 | # base_period_data['names'] == reporting_period_data['names'] |
|
| 382 | # base_period_data['units'] == reporting_period_data['units'] |
|
| 383 | base_period_data_ca_len = len(base_period_data['names']) |
|
| 384 | reporting_period_data_ca_len = len(reporting_period_data['names']) |
|
| 385 | real_timestamps_len = timestamps_data_not_equal_0(report['parameters']['timestamps']) |
|
| 386 | ws['B' + str(current_row_number)].font = title_font |
|
| 387 | ws['B' + str(current_row_number)] = name + ' ' + _('Detailed Data') |
|
| 388 | ||
| 389 | current_row_number += 1 |
|
| 390 | # 1: Stand for blank line 2: Stand for title |
|
| 391 | current_row_number += reporting_period_data_ca_len * 6 + real_timestamps_len * 6 + 1 + 2 |
|
| 392 | table_start_row_number = current_row_number |
|
| 393 | ||
| 394 | has_data = False |
|
| 395 | ||
| 396 | if len(base_period_timestamps[0]) or len(reporting_period_timestamps[0]) > 0: |
|
| 397 | has_data = True |
|
| 398 | ||
| 399 | if has_data: |
|
| 400 | ws.row_dimensions[current_row_number].height = 60 |
|
| 401 | current_col_number = 2 |
|
| 402 | col = format_cell.get_column_letter(current_col_number) |
|
| 403 | ws[col + str(current_row_number)].fill = table_fill |
|
| 404 | ws[col + str(current_row_number)].font = title_font |
|
| 405 | ws[col + str(current_row_number)].border = f_border |
|
| 406 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 407 | ws[col + str(current_row_number)] = _('Base Period') + " - " + _('Datetime') |
|
| 408 | ||
| 409 | for i in range(0, base_period_data_ca_len): |
|
| 410 | current_col_number += 1 |
|
| 411 | col = format_cell.get_column_letter(current_col_number) |
|
| 412 | ||
| 413 | ws[col + str(current_row_number)].fill = table_fill |
|
| 414 | ws[col + str(current_row_number)].font = title_font |
|
| 415 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 416 | ws[col + str(current_row_number)] = _('Base Period') + " - " + base_period_data['names'][i] + \ |
|
| 417 | " (" + base_period_data['units'][i] + ")" |
|
| 418 | ws[col + str(current_row_number)].border = f_border |
|
| 419 | current_col_number += 1 |
|
| 420 | col = format_cell.get_column_letter(current_col_number) |
|
| 421 | ||
| 422 | ws[col + str(current_row_number)].fill = table_fill |
|
| 423 | ws[col + str(current_row_number)].font = title_font |
|
| 424 | ws[col + str(current_row_number)].border = f_border |
|
| 425 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 426 | ws[col + str(current_row_number)] = _('Reporting Period') + " - " + _('Datetime') |
|
| 427 | ||
| 428 | for i in range(0, reporting_period_data_ca_len): |
|
| 429 | current_col_number += 1 |
|
| 430 | col = format_cell.get_column_letter(current_col_number) |
|
| 431 | ws[col + str(current_row_number)].fill = table_fill |
|
| 432 | ws[col + str(current_row_number)].font = title_font |
|
| 433 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 434 | ws[col + str(current_row_number)] = _('Reporting Period') + " - " \ |
|
| 435 | + reporting_period_data['names'][i] + " (" + \ |
|
| 436 | reporting_period_data['units'][i] + ")" |
|
| 437 | ws[col + str(current_row_number)].border = f_border |
|
| 438 | ||
| 439 | current_row_number += 1 |
|
| 440 | ||
| 441 | max_timestamps_len = len(base_period_timestamps[0]) \ |
|
| 442 | if len(base_period_timestamps[0]) >= len(reporting_period_timestamps[0]) \ |
|
| 443 | else len(reporting_period_timestamps[0]) |
|
| 444 | ||
| 445 | for i in range(0, max_timestamps_len): |
|
| 446 | current_col_number = 2 |
|
| 447 | col = format_cell.get_column_letter(current_col_number) |
|
| 448 | ws[col + str(current_row_number)].font = title_font |
|
| 449 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 450 | ws[col + str(current_row_number)] = base_period_timestamps[0][i] \ |
|
| 451 | if i < len(base_period_timestamps[0]) else None |
|
| 452 | ws[col + str(current_row_number)].border = f_border |
|
| 453 | ||
| 454 | for j in range(0, base_period_data_ca_len): |
|
| 455 | current_col_number += 1 |
|
| 456 | col = format_cell.get_column_letter(current_col_number) |
|
| 457 | ||
| 458 | ws[col + str(current_row_number)].font = title_font |
|
| 459 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 460 | ws[col + str(current_row_number)] = round(base_period_data['values'][j][i], 2) \ |
|
| 461 | if i < len(base_period_data['values'][j]) else None |
|
| 462 | ws[col + str(current_row_number)].border = f_border |
|
| 463 | current_col_number += 1 |
|
| 464 | col = format_cell.get_column_letter(current_col_number) |
|
| 465 | ||
| 466 | ws[col + str(current_row_number)].font = title_font |
|
| 467 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 468 | ws[col + str(current_row_number)] = reporting_period_timestamps[0][i] \ |
|
| 469 | if i < len(reporting_period_timestamps[0]) else None |
|
| 470 | ws[col + str(current_row_number)].border = f_border |
|
| 471 | ||
| 472 | for j in range(0, reporting_period_data_ca_len): |
|
| 473 | current_col_number += 1 |
|
| 474 | col = format_cell.get_column_letter(current_col_number) |
|
| 475 | ||
| 476 | ws[col + str(current_row_number)].font = title_font |
|
| 477 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 478 | ws[col + str(current_row_number)] = round(reporting_period_data['values'][j][i], 2) \ |
|
| 479 | if i < len(reporting_period_data['values'][j]) else None |
|
| 480 | ws[col + str(current_row_number)].border = f_border |
|
| 481 | ||
| 482 | current_row_number += 1 |
|
| 483 | ||
| 484 | current_col_number = 2 |
|
| 485 | col = format_cell.get_column_letter(current_col_number) |
|
| 486 | ws[col + str(current_row_number)].font = title_font |
|
| 487 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 488 | ws[col + str(current_row_number)] = _('Subtotal') |
|
| 489 | ws[col + str(current_row_number)].border = f_border |
|
| 490 | ||
| 491 | for i in range(0, base_period_data_ca_len): |
|
| 492 | current_col_number += 1 |
|
| 493 | col = format_cell.get_column_letter(current_col_number) |
|
| 494 | ws[col + str(current_row_number)].font = title_font |
|
| 495 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 496 | ws[col + str(current_row_number)] = round(base_period_data['subtotals'][i], 2) |
|
| 497 | ws[col + str(current_row_number)].border = f_border |
|
| 498 | ||
| 499 | current_col_number += 1 |
|
| 500 | col = format_cell.get_column_letter(current_col_number) |
|
| 501 | ||
| 502 | ws[col + str(current_row_number)].font = title_font |
|
| 503 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 504 | ws[col + str(current_row_number)] = _('Subtotal') |
|
| 505 | ws[col + str(current_row_number)].border = f_border |
|
| 506 | ||
| 507 | for i in range(0, reporting_period_data_ca_len): |
|
| 508 | current_col_number += 1 |
|
| 509 | col = format_cell.get_column_letter(current_col_number) |
|
| 510 | ws[col + str(current_row_number)].font = title_font |
|
| 511 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 512 | ws[col + str(current_row_number)] = round(reporting_period_data['subtotals'][i], 2) |
|
| 513 | ws[col + str(current_row_number)].border = f_border |
|
| 514 | ||
| 515 | for i in range(0, reporting_period_data_ca_len): |
|
| 516 | # line |
|
| 517 | line = LineChart() |
|
| 518 | line.title = _('Base Period Output') + ' / ' \ |
|
| 519 | + _('Reporting Period Output') + ' - ' \ |
|
| 520 | + reporting_period_data['names'][i] + " (" + reporting_period_data['units'][i] + ")" |
|
| 521 | labels = Reference(ws, min_col=2 + base_period_data_ca_len + 1, |
|
| 522 | min_row=table_start_row_number + 1, |
|
| 523 | max_row=table_start_row_number + len(reporting_period_timestamps[0])) |
|
| 524 | base_line_data = Reference(ws, min_col=3 + i, min_row=table_start_row_number, |
|
| 525 | max_row=table_start_row_number + len(reporting_period_timestamps[0])) |
|
| 526 | reporting_line_data = Reference(ws, min_col=3 + base_period_data_ca_len + 1 + i, |
|
| 527 | min_row=table_start_row_number, |
|
| 528 | max_row=table_start_row_number |
|
| 529 | + len(reporting_period_timestamps[0])) |
|
| 530 | line.add_data(base_line_data, titles_from_data=True) |
|
| 531 | line.add_data(reporting_line_data, titles_from_data=True) |
|
| 532 | line.set_categories(labels) |
|
| 533 | for j in range(len(line.series)): |
|
| 534 | line.series[j].marker.symbol = "circle" |
|
| 535 | line.series[j].smooth = True |
|
| 536 | line.x_axis.crosses = 'min' |
|
| 537 | line.height = 8.25 |
|
| 538 | line.width = 24 |
|
| 539 | line.dLbls = DataLabelList() |
|
| 540 | line.dLbls.dLblPos = 't' |
|
| 541 | line.dLbls.showVal = True |
|
| 542 | line.dLbls.showPercent = False |
|
| 543 | chart_col = 'B' |
|
| 544 | chart_cell = chart_col + str(table_start_draw_flag + 6 * i) |
|
| 545 | ws.add_chart(line, chart_cell) |
|
| 546 | ||
| 547 | current_row_number += 2 |
|
| 548 | ||
| 549 | #################################################################################################################### |
|
| 550 | current_sheet_parameters_row_number = table_start_draw_flag + len(reporting_period_data['names']) * 6 + 1 |
|
| @@ 451-736 (lines=286) @@ | ||
| 448 | ||
| 449 | table_start_draw_flag = current_row_number + 1 |
|
| 450 | ||
| 451 | if 'values_saving' not in reporting_period_data.keys() or \ |
|
| 452 | reporting_period_data['values_saving'] is None or \ |
|
| 453 | len(reporting_period_data['values_saving']) == 0 or \ |
|
| 454 | 'timestamps' not in reporting_period_data.keys() or \ |
|
| 455 | reporting_period_data['timestamps'] is None or \ |
|
| 456 | len(reporting_period_data['timestamps']) == 0 or \ |
|
| 457 | len(reporting_period_data['timestamps'][0]) == 0: |
|
| 458 | pass |
|
| 459 | else: |
|
| 460 | if not is_base_period_timestamp_exists_flag: |
|
| 461 | reporting_period_data = report['reporting_period'] |
|
| 462 | times = reporting_period_data['timestamps'] |
|
| 463 | ca_len = len(report['reporting_period']['names']) |
|
| 464 | real_timestamps_len = timestamps_data_not_equal_0(report['parameters']['timestamps']) |
|
| 465 | ws['B' + str(current_row_number)].font = title_font |
|
| 466 | ws['B' + str(current_row_number)] = name + ' ' + _('Detailed Data') |
|
| 467 | ||
| 468 | current_row_number += 1 |
|
| 469 | # 1: Stand for blank line 2: Stand for title |
|
| 470 | current_row_number += ca_len * 6 + real_timestamps_len * 6 + 1 + 2 |
|
| 471 | table_start_row_number = current_row_number |
|
| 472 | ||
| 473 | time = times[0] |
|
| 474 | has_data = False |
|
| 475 | ||
| 476 | if len(time) > 0: |
|
| 477 | has_data = True |
|
| 478 | ||
| 479 | if has_data: |
|
| 480 | ||
| 481 | ws.row_dimensions[current_row_number].height = 60 |
|
| 482 | current_col_number = 2 |
|
| 483 | col = format_cell.get_column_letter(current_col_number) |
|
| 484 | ws[col + str(current_row_number)].fill = table_fill |
|
| 485 | ws[col + str(current_row_number)].font = title_font |
|
| 486 | ws[col + str(current_row_number)].border = f_border |
|
| 487 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 488 | ws[col + str(current_row_number)] = _('Datetime') |
|
| 489 | ||
| 490 | for i in range(0, ca_len): |
|
| 491 | current_col_number += 1 |
|
| 492 | col = format_cell.get_column_letter(current_col_number) |
|
| 493 | ||
| 494 | ws[col + str(current_row_number)].fill = table_fill |
|
| 495 | ws[col + str(current_row_number)].font = title_font |
|
| 496 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 497 | ws[col + str(current_row_number)] = reporting_period_data['names'][i] + \ |
|
| 498 | " (" + reporting_period_data['units'][i] + ")" |
|
| 499 | ws[col + str(current_row_number)].border = f_border |
|
| 500 | ||
| 501 | current_row_number += 1 |
|
| 502 | ||
| 503 | for i in range(0, len(time)): |
|
| 504 | current_col_number = 2 |
|
| 505 | col = format_cell.get_column_letter(current_col_number) |
|
| 506 | ws[col + str(current_row_number)].font = title_font |
|
| 507 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 508 | ws[col + str(current_row_number)] = time[i] |
|
| 509 | ws[col + str(current_row_number)].border = f_border |
|
| 510 | ||
| 511 | for j in range(0, ca_len): |
|
| 512 | current_col_number += 1 |
|
| 513 | col = format_cell.get_column_letter(current_col_number) |
|
| 514 | ||
| 515 | ws[col + str(current_row_number)].font = title_font |
|
| 516 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 517 | ws[col + str(current_row_number)] = round(reporting_period_data['values_saving'][j][i], 2) |
|
| 518 | ws[col + str(current_row_number)].border = f_border |
|
| 519 | ||
| 520 | current_row_number += 1 |
|
| 521 | ||
| 522 | table_end_row_number = current_row_number - 1 |
|
| 523 | ||
| 524 | current_col_number = 2 |
|
| 525 | col = format_cell.get_column_letter(current_col_number) |
|
| 526 | ws[col + str(current_row_number)].font = title_font |
|
| 527 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 528 | ws[col + str(current_row_number)] = _('Subtotal') |
|
| 529 | ws[col + str(current_row_number)].border = f_border |
|
| 530 | ||
| 531 | for i in range(0, ca_len): |
|
| 532 | current_col_number += 1 |
|
| 533 | col = format_cell.get_column_letter(current_col_number) |
|
| 534 | ||
| 535 | ws[col + str(current_row_number)].font = title_font |
|
| 536 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 537 | ws[col + str(current_row_number)] = round(reporting_period_data['subtotals_saving'][i], 2) |
|
| 538 | ws[col + str(current_row_number)].border = f_border |
|
| 539 | ||
| 540 | # line |
|
| 541 | line = LineChart() |
|
| 542 | line.title = _('Reporting Period Saving') + ' - ' \ |
|
| 543 | + reporting_period_data['names'][i] + " (" + reporting_period_data['units'][i] + ")" |
|
| 544 | labels = Reference(ws, min_col=2, min_row=table_start_row_number + 1, max_row=table_end_row_number) |
|
| 545 | line_data = Reference(ws, min_col=3 + i, min_row=table_start_row_number, |
|
| 546 | max_row=table_end_row_number) |
|
| 547 | line.add_data(line_data, titles_from_data=True) |
|
| 548 | line.set_categories(labels) |
|
| 549 | line_data = line.series[0] |
|
| 550 | line_data.marker.symbol = "circle" |
|
| 551 | line_data.smooth = True |
|
| 552 | line.x_axis.crosses = 'min' |
|
| 553 | line.height = 8.25 |
|
| 554 | line.width = 24 |
|
| 555 | line.dLbls = DataLabelList() |
|
| 556 | line.dLbls.dLblPos = 't' |
|
| 557 | line.dLbls.showVal = True |
|
| 558 | line.dLbls.showPercent = False |
|
| 559 | chart_col = 'B' |
|
| 560 | chart_cell = chart_col + str(table_start_draw_flag + 6 * i) |
|
| 561 | ws.add_chart(line, chart_cell) |
|
| 562 | ||
| 563 | current_row_number += 2 |
|
| 564 | else: |
|
| 565 | base_period_data = report['base_period'] |
|
| 566 | reporting_period_data = report['reporting_period'] |
|
| 567 | base_period_timestamps = base_period_data['timestamps'] |
|
| 568 | reporting_period_timestamps = reporting_period_data['timestamps'] |
|
| 569 | # Tip: |
|
| 570 | # base_period_data['names'] == reporting_period_data['names'] |
|
| 571 | # base_period_data['units'] == reporting_period_data['units'] |
|
| 572 | base_period_data_ca_len = len(base_period_data['names']) |
|
| 573 | reporting_period_data_ca_len = len(reporting_period_data['names']) |
|
| 574 | real_timestamps_len = timestamps_data_not_equal_0(report['parameters']['timestamps']) |
|
| 575 | ws['B' + str(current_row_number)].font = title_font |
|
| 576 | ws['B' + str(current_row_number)] = name + ' ' + _('Detailed Data') |
|
| 577 | ||
| 578 | current_row_number += 1 |
|
| 579 | # 1: Stand for blank line 2: Stand for title |
|
| 580 | current_row_number += reporting_period_data_ca_len * 6 + real_timestamps_len * 6 + 1 + 2 |
|
| 581 | table_start_row_number = current_row_number |
|
| 582 | ||
| 583 | has_data = False |
|
| 584 | ||
| 585 | if len(base_period_timestamps[0]) or len(reporting_period_timestamps[0]) > 0: |
|
| 586 | has_data = True |
|
| 587 | ||
| 588 | if has_data: |
|
| 589 | ws.row_dimensions[current_row_number].height = 60 |
|
| 590 | current_col_number = 2 |
|
| 591 | col = format_cell.get_column_letter(current_col_number) |
|
| 592 | ws[col + str(current_row_number)].fill = table_fill |
|
| 593 | ws[col + str(current_row_number)].font = title_font |
|
| 594 | ws[col + str(current_row_number)].border = f_border |
|
| 595 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 596 | ws[col + str(current_row_number)] = _('Base Period') + " - " + _('Datetime') |
|
| 597 | ||
| 598 | for i in range(0, base_period_data_ca_len): |
|
| 599 | current_col_number += 1 |
|
| 600 | col = format_cell.get_column_letter(current_col_number) |
|
| 601 | ||
| 602 | ws[col + str(current_row_number)].fill = table_fill |
|
| 603 | ws[col + str(current_row_number)].font = title_font |
|
| 604 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 605 | ws[col + str(current_row_number)] = _('Base Period') + " - " + base_period_data['names'][i] + \ |
|
| 606 | " (" + base_period_data['units'][i] + ")" |
|
| 607 | ws[col + str(current_row_number)].border = f_border |
|
| 608 | current_col_number += 1 |
|
| 609 | col = format_cell.get_column_letter(current_col_number) |
|
| 610 | ||
| 611 | ws[col + str(current_row_number)].fill = table_fill |
|
| 612 | ws[col + str(current_row_number)].font = title_font |
|
| 613 | ws[col + str(current_row_number)].border = f_border |
|
| 614 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 615 | ws[col + str(current_row_number)] = _('Reporting Period') + " - " + _('Datetime') |
|
| 616 | ||
| 617 | for i in range(0, reporting_period_data_ca_len): |
|
| 618 | current_col_number += 1 |
|
| 619 | col = format_cell.get_column_letter(current_col_number) |
|
| 620 | ws[col + str(current_row_number)].fill = table_fill |
|
| 621 | ws[col + str(current_row_number)].font = title_font |
|
| 622 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 623 | ws[col + str(current_row_number)] = _('Reporting Period') + " - " \ |
|
| 624 | + reporting_period_data['names'][i] + " (" + \ |
|
| 625 | reporting_period_data['units'][i] + ")" |
|
| 626 | ws[col + str(current_row_number)].border = f_border |
|
| 627 | ||
| 628 | current_row_number += 1 |
|
| 629 | ||
| 630 | max_timestamps_len = len(base_period_timestamps[0]) \ |
|
| 631 | if len(base_period_timestamps[0]) >= len(reporting_period_timestamps[0]) \ |
|
| 632 | else len(reporting_period_timestamps[0]) |
|
| 633 | ||
| 634 | for i in range(0, max_timestamps_len): |
|
| 635 | current_col_number = 2 |
|
| 636 | col = format_cell.get_column_letter(current_col_number) |
|
| 637 | ws[col + str(current_row_number)].font = title_font |
|
| 638 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 639 | ws[col + str(current_row_number)] = base_period_timestamps[0][i] \ |
|
| 640 | if i < len(base_period_timestamps[0]) else None |
|
| 641 | ws[col + str(current_row_number)].border = f_border |
|
| 642 | ||
| 643 | for j in range(0, base_period_data_ca_len): |
|
| 644 | current_col_number += 1 |
|
| 645 | col = format_cell.get_column_letter(current_col_number) |
|
| 646 | ||
| 647 | ws[col + str(current_row_number)].font = title_font |
|
| 648 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 649 | ws[col + str(current_row_number)] = round(base_period_data['values_saving'][j][i], 2) \ |
|
| 650 | if i < len(base_period_data['values_saving'][j]) else None |
|
| 651 | ws[col + str(current_row_number)].border = f_border |
|
| 652 | current_col_number += 1 |
|
| 653 | col = format_cell.get_column_letter(current_col_number) |
|
| 654 | ||
| 655 | ws[col + str(current_row_number)].font = title_font |
|
| 656 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 657 | ws[col + str(current_row_number)] = reporting_period_timestamps[0][i] \ |
|
| 658 | if i < len(reporting_period_timestamps[0]) else None |
|
| 659 | ws[col + str(current_row_number)].border = f_border |
|
| 660 | ||
| 661 | for j in range(0, reporting_period_data_ca_len): |
|
| 662 | current_col_number += 1 |
|
| 663 | col = format_cell.get_column_letter(current_col_number) |
|
| 664 | ||
| 665 | ws[col + str(current_row_number)].font = title_font |
|
| 666 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 667 | ws[col + str(current_row_number)] = round(reporting_period_data['values_saving'][j][i], 2) \ |
|
| 668 | if i < len(reporting_period_data['values_saving'][j]) else None |
|
| 669 | ws[col + str(current_row_number)].border = f_border |
|
| 670 | ||
| 671 | current_row_number += 1 |
|
| 672 | ||
| 673 | current_col_number = 2 |
|
| 674 | col = format_cell.get_column_letter(current_col_number) |
|
| 675 | ws[col + str(current_row_number)].font = title_font |
|
| 676 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 677 | ws[col + str(current_row_number)] = _('Subtotal') |
|
| 678 | ws[col + str(current_row_number)].border = f_border |
|
| 679 | ||
| 680 | for i in range(0, base_period_data_ca_len): |
|
| 681 | current_col_number += 1 |
|
| 682 | col = format_cell.get_column_letter(current_col_number) |
|
| 683 | ws[col + str(current_row_number)].font = title_font |
|
| 684 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 685 | ws[col + str(current_row_number)] = round(base_period_data['subtotals_saving'][i], 2) |
|
| 686 | ws[col + str(current_row_number)].border = f_border |
|
| 687 | ||
| 688 | current_col_number += 1 |
|
| 689 | col = format_cell.get_column_letter(current_col_number) |
|
| 690 | ||
| 691 | ws[col + str(current_row_number)].font = title_font |
|
| 692 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 693 | ws[col + str(current_row_number)] = _('Subtotal') |
|
| 694 | ws[col + str(current_row_number)].border = f_border |
|
| 695 | ||
| 696 | for i in range(0, reporting_period_data_ca_len): |
|
| 697 | current_col_number += 1 |
|
| 698 | col = format_cell.get_column_letter(current_col_number) |
|
| 699 | ws[col + str(current_row_number)].font = title_font |
|
| 700 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 701 | ws[col + str(current_row_number)] = round(reporting_period_data['subtotals_saving'][i], 2) |
|
| 702 | ws[col + str(current_row_number)].border = f_border |
|
| 703 | ||
| 704 | for i in range(0, reporting_period_data_ca_len): |
|
| 705 | # line |
|
| 706 | line = LineChart() |
|
| 707 | line.title = _('Base Period Saving') + ' / ' \ |
|
| 708 | + _('Reporting Period Saving') + ' - ' \ |
|
| 709 | + reporting_period_data['names'][i] + " (" + reporting_period_data['units'][i] + ")" |
|
| 710 | labels = Reference(ws, min_col=2 + base_period_data_ca_len + 1, |
|
| 711 | min_row=table_start_row_number + 1, |
|
| 712 | max_row=table_start_row_number + len(reporting_period_timestamps[0])) |
|
| 713 | base_line_data = Reference(ws, min_col=3 + i, min_row=table_start_row_number, |
|
| 714 | max_row=table_start_row_number + len(reporting_period_timestamps[0])) |
|
| 715 | reporting_line_data = Reference(ws, min_col=3 + base_period_data_ca_len + 1 + i, |
|
| 716 | min_row=table_start_row_number, |
|
| 717 | max_row=table_start_row_number |
|
| 718 | + len(reporting_period_timestamps[0])) |
|
| 719 | line.add_data(base_line_data, titles_from_data=True) |
|
| 720 | line.add_data(reporting_line_data, titles_from_data=True) |
|
| 721 | line.set_categories(labels) |
|
| 722 | for j in range(len(line.series)): |
|
| 723 | line.series[j].marker.symbol = "circle" |
|
| 724 | line.series[j].smooth = True |
|
| 725 | line.x_axis.crosses = 'min' |
|
| 726 | line.height = 8.25 |
|
| 727 | line.width = 24 |
|
| 728 | line.dLbls = DataLabelList() |
|
| 729 | line.dLbls.dLblPos = 't' |
|
| 730 | line.dLbls.showVal = True |
|
| 731 | line.dLbls.showPercent = False |
|
| 732 | chart_col = 'B' |
|
| 733 | chart_cell = chart_col + str(table_start_draw_flag + 6 * i) |
|
| 734 | ws.add_chart(line, chart_cell) |
|
| 735 | ||
| 736 | current_row_number += 2 |
|
| 737 | ||
| 738 | #################################################################################################################### |
|
| 739 | current_sheet_parameters_row_number = table_start_draw_flag + len(reporting_period_data['names']) * 6 + 1 |
|
| @@ 487-771 (lines=285) @@ | ||
| 484 | #################################################################################################################### |
|
| 485 | table_start_draw_flag = current_row_number + 1 |
|
| 486 | ||
| 487 | if 'values_saving' not in reporting_period_data.keys() or \ |
|
| 488 | reporting_period_data['values_saving'] is None or \ |
|
| 489 | len(reporting_period_data['values_saving']) == 0 or \ |
|
| 490 | 'timestamps' not in reporting_period_data.keys() or \ |
|
| 491 | reporting_period_data['timestamps'] is None or \ |
|
| 492 | len(reporting_period_data['timestamps']) == 0 or \ |
|
| 493 | len(reporting_period_data['timestamps'][0]) == 0: |
|
| 494 | pass |
|
| 495 | else: |
|
| 496 | if not is_base_period_timestamp_exists_flag: |
|
| 497 | reporting_period_data = report['reporting_period'] |
|
| 498 | times = reporting_period_data['timestamps'] |
|
| 499 | ca_len = len(report['reporting_period']['names']) |
|
| 500 | real_timestamps_len = timestamps_data_not_equal_0(report['parameters']['timestamps']) |
|
| 501 | ws['B' + str(current_row_number)].font = title_font |
|
| 502 | ws['B' + str(current_row_number)] = name + ' ' + _('Detailed Data') |
|
| 503 | ||
| 504 | current_row_number += 1 |
|
| 505 | # 1: Stand for blank line 2: Stand for title |
|
| 506 | current_row_number += ca_len * 6 + real_timestamps_len * 6 + 1 + 2 |
|
| 507 | table_start_row_number = current_row_number |
|
| 508 | ||
| 509 | time = times[0] |
|
| 510 | has_data = False |
|
| 511 | ||
| 512 | if len(time) > 0: |
|
| 513 | has_data = True |
|
| 514 | ||
| 515 | if has_data: |
|
| 516 | ||
| 517 | ws.row_dimensions[current_row_number].height = 60 |
|
| 518 | current_col_number = 2 |
|
| 519 | col = format_cell.get_column_letter(current_col_number) |
|
| 520 | ws[col + str(current_row_number)].fill = table_fill |
|
| 521 | ws[col + str(current_row_number)].font = title_font |
|
| 522 | ws[col + str(current_row_number)].border = f_border |
|
| 523 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 524 | ws[col + str(current_row_number)] = _('Datetime') |
|
| 525 | ||
| 526 | for i in range(0, ca_len): |
|
| 527 | current_col_number += 1 |
|
| 528 | col = format_cell.get_column_letter(current_col_number) |
|
| 529 | ||
| 530 | ws[col + str(current_row_number)].fill = table_fill |
|
| 531 | ws[col + str(current_row_number)].font = title_font |
|
| 532 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 533 | ws[col + str(current_row_number)] = reporting_period_data['names'][i] + \ |
|
| 534 | " (" + reporting_period_data['units'][i] + ")" |
|
| 535 | ws[col + str(current_row_number)].border = f_border |
|
| 536 | ||
| 537 | current_row_number += 1 |
|
| 538 | ||
| 539 | for i in range(0, len(time)): |
|
| 540 | current_col_number = 2 |
|
| 541 | col = format_cell.get_column_letter(current_col_number) |
|
| 542 | ws[col + str(current_row_number)].font = title_font |
|
| 543 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 544 | ws[col + str(current_row_number)] = time[i] |
|
| 545 | ws[col + str(current_row_number)].border = f_border |
|
| 546 | ||
| 547 | for j in range(0, ca_len): |
|
| 548 | current_col_number += 1 |
|
| 549 | col = format_cell.get_column_letter(current_col_number) |
|
| 550 | ||
| 551 | ws[col + str(current_row_number)].font = title_font |
|
| 552 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 553 | ws[col + str(current_row_number)] = round(reporting_period_data['values_saving'][j][i], 2) |
|
| 554 | ws[col + str(current_row_number)].border = f_border |
|
| 555 | ||
| 556 | current_row_number += 1 |
|
| 557 | ||
| 558 | table_end_row_number = current_row_number - 1 |
|
| 559 | ||
| 560 | current_col_number = 2 |
|
| 561 | col = format_cell.get_column_letter(current_col_number) |
|
| 562 | ws[col + str(current_row_number)].font = title_font |
|
| 563 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 564 | ws[col + str(current_row_number)] = _('Subtotal') |
|
| 565 | ws[col + str(current_row_number)].border = f_border |
|
| 566 | ||
| 567 | for i in range(0, ca_len): |
|
| 568 | current_col_number += 1 |
|
| 569 | col = format_cell.get_column_letter(current_col_number) |
|
| 570 | ||
| 571 | ws[col + str(current_row_number)].font = title_font |
|
| 572 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 573 | ws[col + str(current_row_number)] = round(reporting_period_data['subtotals_saving'][i], 2) |
|
| 574 | ws[col + str(current_row_number)].border = f_border |
|
| 575 | ||
| 576 | # line |
|
| 577 | line = LineChart() |
|
| 578 | line.title = _('Reporting Period Saving') + ' - ' \ |
|
| 579 | + reporting_period_data['names'][i] + " (" + reporting_period_data['units'][i] + ")" |
|
| 580 | labels = Reference(ws, min_col=2, min_row=table_start_row_number + 1, max_row=table_end_row_number) |
|
| 581 | line_data = Reference(ws, min_col=3 + i, min_row=table_start_row_number, |
|
| 582 | max_row=table_end_row_number) |
|
| 583 | line.add_data(line_data, titles_from_data=True) |
|
| 584 | line.set_categories(labels) |
|
| 585 | line_data = line.series[0] |
|
| 586 | line_data.marker.symbol = "circle" |
|
| 587 | line_data.smooth = True |
|
| 588 | line.x_axis.crosses = 'min' |
|
| 589 | line.height = 8.25 |
|
| 590 | line.width = 24 |
|
| 591 | line.dLbls = DataLabelList() |
|
| 592 | line.dLbls.dLblPos = 't' |
|
| 593 | line.dLbls.showVal = True |
|
| 594 | line.dLbls.showPercent = False |
|
| 595 | chart_col = 'B' |
|
| 596 | chart_cell = chart_col + str(table_start_draw_flag + 6 * i) |
|
| 597 | ws.add_chart(line, chart_cell) |
|
| 598 | ||
| 599 | current_row_number += 2 |
|
| 600 | else: |
|
| 601 | base_period_data = report['base_period'] |
|
| 602 | reporting_period_data = report['reporting_period'] |
|
| 603 | base_period_timestamps = base_period_data['timestamps'] |
|
| 604 | reporting_period_timestamps = reporting_period_data['timestamps'] |
|
| 605 | # Tip: |
|
| 606 | # base_period_data['names'] == reporting_period_data['names'] |
|
| 607 | # base_period_data['units'] == reporting_period_data['units'] |
|
| 608 | base_period_data_ca_len = len(base_period_data['names']) |
|
| 609 | reporting_period_data_ca_len = len(reporting_period_data['names']) |
|
| 610 | real_timestamps_len = timestamps_data_not_equal_0(report['parameters']['timestamps']) |
|
| 611 | ws['B' + str(current_row_number)].font = title_font |
|
| 612 | ws['B' + str(current_row_number)] = name + ' ' + _('Detailed Data') |
|
| 613 | ||
| 614 | current_row_number += 1 |
|
| 615 | # 1: Stand for blank line 2: Stand for title |
|
| 616 | current_row_number += reporting_period_data_ca_len * 6 + real_timestamps_len * 6 + 1 + 2 |
|
| 617 | table_start_row_number = current_row_number |
|
| 618 | ||
| 619 | has_data = False |
|
| 620 | ||
| 621 | if len(base_period_timestamps[0]) or len(reporting_period_timestamps[0]) > 0: |
|
| 622 | has_data = True |
|
| 623 | ||
| 624 | if has_data: |
|
| 625 | ws.row_dimensions[current_row_number].height = 60 |
|
| 626 | current_col_number = 2 |
|
| 627 | col = format_cell.get_column_letter(current_col_number) |
|
| 628 | ws[col + str(current_row_number)].fill = table_fill |
|
| 629 | ws[col + str(current_row_number)].font = title_font |
|
| 630 | ws[col + str(current_row_number)].border = f_border |
|
| 631 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 632 | ws[col + str(current_row_number)] = _('Base Period') + " - " + _('Datetime') |
|
| 633 | ||
| 634 | for i in range(0, base_period_data_ca_len): |
|
| 635 | current_col_number += 1 |
|
| 636 | col = format_cell.get_column_letter(current_col_number) |
|
| 637 | ||
| 638 | ws[col + str(current_row_number)].fill = table_fill |
|
| 639 | ws[col + str(current_row_number)].font = title_font |
|
| 640 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 641 | ws[col + str(current_row_number)] = _('Base Period') + " - " + base_period_data['names'][i] + \ |
|
| 642 | " (" + base_period_data['units'][i] + ")" |
|
| 643 | ws[col + str(current_row_number)].border = f_border |
|
| 644 | current_col_number += 1 |
|
| 645 | col = format_cell.get_column_letter(current_col_number) |
|
| 646 | ||
| 647 | ws[col + str(current_row_number)].fill = table_fill |
|
| 648 | ws[col + str(current_row_number)].font = title_font |
|
| 649 | ws[col + str(current_row_number)].border = f_border |
|
| 650 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 651 | ws[col + str(current_row_number)] = _('Reporting Period') + " - " + _('Datetime') |
|
| 652 | ||
| 653 | for i in range(0, reporting_period_data_ca_len): |
|
| 654 | current_col_number += 1 |
|
| 655 | col = format_cell.get_column_letter(current_col_number) |
|
| 656 | ws[col + str(current_row_number)].fill = table_fill |
|
| 657 | ws[col + str(current_row_number)].font = title_font |
|
| 658 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 659 | ws[col + str(current_row_number)] = _('Reporting Period') + " - " \ |
|
| 660 | + reporting_period_data['names'][i] + " (" + reporting_period_data['units'][i] + ")" |
|
| 661 | ws[col + str(current_row_number)].border = f_border |
|
| 662 | ||
| 663 | current_row_number += 1 |
|
| 664 | ||
| 665 | max_timestamps_len = len(base_period_timestamps[0]) \ |
|
| 666 | if len(base_period_timestamps[0]) >= len(reporting_period_timestamps[0]) \ |
|
| 667 | else len(reporting_period_timestamps[0]) |
|
| 668 | ||
| 669 | for i in range(0, max_timestamps_len): |
|
| 670 | current_col_number = 2 |
|
| 671 | col = format_cell.get_column_letter(current_col_number) |
|
| 672 | ws[col + str(current_row_number)].font = title_font |
|
| 673 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 674 | ws[col + str(current_row_number)] = base_period_timestamps[0][i] \ |
|
| 675 | if i < len(base_period_timestamps[0]) else None |
|
| 676 | ws[col + str(current_row_number)].border = f_border |
|
| 677 | ||
| 678 | for j in range(0, base_period_data_ca_len): |
|
| 679 | current_col_number += 1 |
|
| 680 | col = format_cell.get_column_letter(current_col_number) |
|
| 681 | ||
| 682 | ws[col + str(current_row_number)].font = title_font |
|
| 683 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 684 | ws[col + str(current_row_number)] = round(base_period_data['values_saving'][j][i], 2) \ |
|
| 685 | if i < len(base_period_data['values_saving'][j]) else None |
|
| 686 | ws[col + str(current_row_number)].border = f_border |
|
| 687 | current_col_number += 1 |
|
| 688 | col = format_cell.get_column_letter(current_col_number) |
|
| 689 | ||
| 690 | ws[col + str(current_row_number)].font = title_font |
|
| 691 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 692 | ws[col + str(current_row_number)] = reporting_period_timestamps[0][i] \ |
|
| 693 | if i < len(reporting_period_timestamps[0]) else None |
|
| 694 | ws[col + str(current_row_number)].border = f_border |
|
| 695 | ||
| 696 | for j in range(0, reporting_period_data_ca_len): |
|
| 697 | current_col_number += 1 |
|
| 698 | col = format_cell.get_column_letter(current_col_number) |
|
| 699 | ||
| 700 | ws[col + str(current_row_number)].font = title_font |
|
| 701 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 702 | ws[col + str(current_row_number)] = round(reporting_period_data['values_saving'][j][i], 2) \ |
|
| 703 | if i < len(reporting_period_data['values_saving'][j]) else None |
|
| 704 | ws[col + str(current_row_number)].border = f_border |
|
| 705 | ||
| 706 | current_row_number += 1 |
|
| 707 | ||
| 708 | current_col_number = 2 |
|
| 709 | col = format_cell.get_column_letter(current_col_number) |
|
| 710 | ws[col + str(current_row_number)].font = title_font |
|
| 711 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 712 | ws[col + str(current_row_number)] = _('Subtotal') |
|
| 713 | ws[col + str(current_row_number)].border = f_border |
|
| 714 | ||
| 715 | for i in range(0, base_period_data_ca_len): |
|
| 716 | current_col_number += 1 |
|
| 717 | col = format_cell.get_column_letter(current_col_number) |
|
| 718 | ws[col + str(current_row_number)].font = title_font |
|
| 719 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 720 | ws[col + str(current_row_number)] = round(base_period_data['subtotals_saving'][i], 2) |
|
| 721 | ws[col + str(current_row_number)].border = f_border |
|
| 722 | ||
| 723 | current_col_number += 1 |
|
| 724 | col = format_cell.get_column_letter(current_col_number) |
|
| 725 | ||
| 726 | ws[col + str(current_row_number)].font = title_font |
|
| 727 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 728 | ws[col + str(current_row_number)] = _('Subtotal') |
|
| 729 | ws[col + str(current_row_number)].border = f_border |
|
| 730 | ||
| 731 | for i in range(0, reporting_period_data_ca_len): |
|
| 732 | current_col_number += 1 |
|
| 733 | col = format_cell.get_column_letter(current_col_number) |
|
| 734 | ws[col + str(current_row_number)].font = title_font |
|
| 735 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 736 | ws[col + str(current_row_number)] = round(reporting_period_data['subtotals_saving'][i], 2) |
|
| 737 | ws[col + str(current_row_number)].border = f_border |
|
| 738 | ||
| 739 | for i in range(0, reporting_period_data_ca_len): |
|
| 740 | # line |
|
| 741 | line = LineChart() |
|
| 742 | line.title = _('Base Period Saving') + ' / ' \ |
|
| 743 | + _('Reporting Period Saving') + ' - ' \ |
|
| 744 | + reporting_period_data['names'][i] + " (" + reporting_period_data['units'][i] + ")" |
|
| 745 | labels = Reference(ws, min_col=2 + base_period_data_ca_len + 1, |
|
| 746 | min_row=table_start_row_number + 1, |
|
| 747 | max_row=table_start_row_number + len(reporting_period_timestamps[0])) |
|
| 748 | base_line_data = Reference(ws, min_col=3 + i, min_row=table_start_row_number, |
|
| 749 | max_row=table_start_row_number + len(reporting_period_timestamps[0])) |
|
| 750 | reporting_line_data = Reference(ws, min_col=3 + base_period_data_ca_len + 1 + i, |
|
| 751 | min_row=table_start_row_number, |
|
| 752 | max_row=table_start_row_number |
|
| 753 | + len(reporting_period_timestamps[0])) |
|
| 754 | line.add_data(base_line_data, titles_from_data=True) |
|
| 755 | line.add_data(reporting_line_data, titles_from_data=True) |
|
| 756 | line.set_categories(labels) |
|
| 757 | for j in range(len(line.series)): |
|
| 758 | line.series[j].marker.symbol = "circle" |
|
| 759 | line.series[j].smooth = True |
|
| 760 | line.x_axis.crosses = 'min' |
|
| 761 | line.height = 8.25 |
|
| 762 | line.width = 24 |
|
| 763 | line.dLbls = DataLabelList() |
|
| 764 | line.dLbls.dLblPos = 't' |
|
| 765 | line.dLbls.showVal = True |
|
| 766 | line.dLbls.showPercent = False |
|
| 767 | chart_col = 'B' |
|
| 768 | chart_cell = chart_col + str(table_start_draw_flag + 6 * i) |
|
| 769 | ws.add_chart(line, chart_cell) |
|
| 770 | ||
| 771 | current_row_number += 2 |
|
| 772 | ||
| 773 | #################################################################################################################### |
|
| 774 | current_sheet_parameters_row_number = table_start_draw_flag + len(reporting_period_data['names']) * 6 + 1 |
|
| @@ 481-765 (lines=285) @@ | ||
| 478 | #################################################################################################################### |
|
| 479 | table_start_draw_flag = current_row_number + 1 |
|
| 480 | ||
| 481 | if 'values_saving' not in reporting_period_data.keys() or \ |
|
| 482 | reporting_period_data['values_saving'] is None or \ |
|
| 483 | len(reporting_period_data['values_saving']) == 0 or \ |
|
| 484 | 'timestamps' not in reporting_period_data.keys() or \ |
|
| 485 | reporting_period_data['timestamps'] is None or \ |
|
| 486 | len(reporting_period_data['timestamps']) == 0 or \ |
|
| 487 | len(reporting_period_data['timestamps'][0]) == 0: |
|
| 488 | pass |
|
| 489 | else: |
|
| 490 | if not is_base_period_timestamp_exists_flag: |
|
| 491 | reporting_period_data = report['reporting_period'] |
|
| 492 | times = reporting_period_data['timestamps'] |
|
| 493 | ca_len = len(report['reporting_period']['names']) |
|
| 494 | real_timestamps_len = timestamps_data_not_equal_0(report['parameters']['timestamps']) |
|
| 495 | ws['B' + str(current_row_number)].font = title_font |
|
| 496 | ws['B' + str(current_row_number)] = name + ' ' + _('Detailed Data') |
|
| 497 | ||
| 498 | current_row_number += 1 |
|
| 499 | # 1: Stand for blank line 2: Stand for title |
|
| 500 | current_row_number += ca_len * 6 + real_timestamps_len * 6 + 1 + 2 |
|
| 501 | table_start_row_number = current_row_number |
|
| 502 | ||
| 503 | time = times[0] |
|
| 504 | has_data = False |
|
| 505 | ||
| 506 | if len(time) > 0: |
|
| 507 | has_data = True |
|
| 508 | ||
| 509 | if has_data: |
|
| 510 | ||
| 511 | ws.row_dimensions[current_row_number].height = 60 |
|
| 512 | current_col_number = 2 |
|
| 513 | col = format_cell.get_column_letter(current_col_number) |
|
| 514 | ws[col + str(current_row_number)].fill = table_fill |
|
| 515 | ws[col + str(current_row_number)].font = title_font |
|
| 516 | ws[col + str(current_row_number)].border = f_border |
|
| 517 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 518 | ws[col + str(current_row_number)] = _('Datetime') |
|
| 519 | ||
| 520 | for i in range(0, ca_len): |
|
| 521 | current_col_number += 1 |
|
| 522 | col = format_cell.get_column_letter(current_col_number) |
|
| 523 | ||
| 524 | ws[col + str(current_row_number)].fill = table_fill |
|
| 525 | ws[col + str(current_row_number)].font = title_font |
|
| 526 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 527 | ws[col + str(current_row_number)] = reporting_period_data['names'][i] + \ |
|
| 528 | " (" + reporting_period_data['units'][i] + ")" |
|
| 529 | ws[col + str(current_row_number)].border = f_border |
|
| 530 | ||
| 531 | current_row_number += 1 |
|
| 532 | ||
| 533 | for i in range(0, len(time)): |
|
| 534 | current_col_number = 2 |
|
| 535 | col = format_cell.get_column_letter(current_col_number) |
|
| 536 | ws[col + str(current_row_number)].font = title_font |
|
| 537 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 538 | ws[col + str(current_row_number)] = time[i] |
|
| 539 | ws[col + str(current_row_number)].border = f_border |
|
| 540 | ||
| 541 | for j in range(0, ca_len): |
|
| 542 | current_col_number += 1 |
|
| 543 | col = format_cell.get_column_letter(current_col_number) |
|
| 544 | ||
| 545 | ws[col + str(current_row_number)].font = title_font |
|
| 546 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 547 | ws[col + str(current_row_number)] = round(reporting_period_data['values_saving'][j][i], 2) |
|
| 548 | ws[col + str(current_row_number)].border = f_border |
|
| 549 | ||
| 550 | current_row_number += 1 |
|
| 551 | ||
| 552 | table_end_row_number = current_row_number - 1 |
|
| 553 | ||
| 554 | current_col_number = 2 |
|
| 555 | col = format_cell.get_column_letter(current_col_number) |
|
| 556 | ws[col + str(current_row_number)].font = title_font |
|
| 557 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 558 | ws[col + str(current_row_number)] = _('Subtotal') |
|
| 559 | ws[col + str(current_row_number)].border = f_border |
|
| 560 | ||
| 561 | for i in range(0, ca_len): |
|
| 562 | current_col_number += 1 |
|
| 563 | col = format_cell.get_column_letter(current_col_number) |
|
| 564 | ||
| 565 | ws[col + str(current_row_number)].font = title_font |
|
| 566 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 567 | ws[col + str(current_row_number)] = round(reporting_period_data['subtotals_saving'][i], 2) |
|
| 568 | ws[col + str(current_row_number)].border = f_border |
|
| 569 | ||
| 570 | # line |
|
| 571 | line = LineChart() |
|
| 572 | line.title = _('Reporting Period Saving') + ' - ' \ |
|
| 573 | + reporting_period_data['names'][i] + " (" + reporting_period_data['units'][i] + ")" |
|
| 574 | labels = Reference(ws, min_col=2, min_row=table_start_row_number + 1, max_row=table_end_row_number) |
|
| 575 | line_data = Reference(ws, min_col=3 + i, min_row=table_start_row_number, |
|
| 576 | max_row=table_end_row_number) |
|
| 577 | line.add_data(line_data, titles_from_data=True) |
|
| 578 | line.set_categories(labels) |
|
| 579 | line_data = line.series[0] |
|
| 580 | line_data.marker.symbol = "circle" |
|
| 581 | line_data.smooth = True |
|
| 582 | line.x_axis.crosses = 'min' |
|
| 583 | line.height = 8.25 |
|
| 584 | line.width = 24 |
|
| 585 | line.dLbls = DataLabelList() |
|
| 586 | line.dLbls.dLblPos = 't' |
|
| 587 | line.dLbls.showVal = True |
|
| 588 | line.dLbls.showPercent = False |
|
| 589 | chart_col = 'B' |
|
| 590 | chart_cell = chart_col + str(table_start_draw_flag + 6 * i) |
|
| 591 | ws.add_chart(line, chart_cell) |
|
| 592 | ||
| 593 | current_row_number += 2 |
|
| 594 | else: |
|
| 595 | base_period_data = report['base_period'] |
|
| 596 | reporting_period_data = report['reporting_period'] |
|
| 597 | base_period_timestamps = base_period_data['timestamps'] |
|
| 598 | reporting_period_timestamps = reporting_period_data['timestamps'] |
|
| 599 | # Tip: |
|
| 600 | # base_period_data['names'] == reporting_period_data['names'] |
|
| 601 | # base_period_data['units'] == reporting_period_data['units'] |
|
| 602 | base_period_data_ca_len = len(base_period_data['names']) |
|
| 603 | reporting_period_data_ca_len = len(reporting_period_data['names']) |
|
| 604 | real_timestamps_len = timestamps_data_not_equal_0(report['parameters']['timestamps']) |
|
| 605 | ws['B' + str(current_row_number)].font = title_font |
|
| 606 | ws['B' + str(current_row_number)] = name + ' ' + _('Detailed Data') |
|
| 607 | ||
| 608 | current_row_number += 1 |
|
| 609 | # 1: Stand for blank line 2: Stand for title |
|
| 610 | current_row_number += reporting_period_data_ca_len * 6 + real_timestamps_len * 6 + 1 + 2 |
|
| 611 | table_start_row_number = current_row_number |
|
| 612 | ||
| 613 | has_data = False |
|
| 614 | ||
| 615 | if len(base_period_timestamps[0]) or len(reporting_period_timestamps[0]) > 0: |
|
| 616 | has_data = True |
|
| 617 | ||
| 618 | if has_data: |
|
| 619 | ws.row_dimensions[current_row_number].height = 60 |
|
| 620 | current_col_number = 2 |
|
| 621 | col = format_cell.get_column_letter(current_col_number) |
|
| 622 | ws[col + str(current_row_number)].fill = table_fill |
|
| 623 | ws[col + str(current_row_number)].font = title_font |
|
| 624 | ws[col + str(current_row_number)].border = f_border |
|
| 625 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 626 | ws[col + str(current_row_number)] = _('Base Period') + " - " + _('Datetime') |
|
| 627 | ||
| 628 | for i in range(0, base_period_data_ca_len): |
|
| 629 | current_col_number += 1 |
|
| 630 | col = format_cell.get_column_letter(current_col_number) |
|
| 631 | ||
| 632 | ws[col + str(current_row_number)].fill = table_fill |
|
| 633 | ws[col + str(current_row_number)].font = title_font |
|
| 634 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 635 | ws[col + str(current_row_number)] = _('Base Period') + " - " + base_period_data['names'][i] + \ |
|
| 636 | " (" + base_period_data['units'][i] + ")" |
|
| 637 | ws[col + str(current_row_number)].border = f_border |
|
| 638 | current_col_number += 1 |
|
| 639 | col = format_cell.get_column_letter(current_col_number) |
|
| 640 | ||
| 641 | ws[col + str(current_row_number)].fill = table_fill |
|
| 642 | ws[col + str(current_row_number)].font = title_font |
|
| 643 | ws[col + str(current_row_number)].border = f_border |
|
| 644 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 645 | ws[col + str(current_row_number)] = _('Reporting Period') + " - " + _('Datetime') |
|
| 646 | ||
| 647 | for i in range(0, reporting_period_data_ca_len): |
|
| 648 | current_col_number += 1 |
|
| 649 | col = format_cell.get_column_letter(current_col_number) |
|
| 650 | ws[col + str(current_row_number)].fill = table_fill |
|
| 651 | ws[col + str(current_row_number)].font = title_font |
|
| 652 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 653 | ws[col + str(current_row_number)] = _('Reporting Period') + " - " \ |
|
| 654 | + reporting_period_data['names'][i] + " (" + reporting_period_data['units'][i] + ")" |
|
| 655 | ws[col + str(current_row_number)].border = f_border |
|
| 656 | ||
| 657 | current_row_number += 1 |
|
| 658 | ||
| 659 | max_timestamps_len = len(base_period_timestamps[0]) \ |
|
| 660 | if len(base_period_timestamps[0]) >= len(reporting_period_timestamps[0]) \ |
|
| 661 | else len(reporting_period_timestamps[0]) |
|
| 662 | ||
| 663 | for i in range(0, max_timestamps_len): |
|
| 664 | current_col_number = 2 |
|
| 665 | col = format_cell.get_column_letter(current_col_number) |
|
| 666 | ws[col + str(current_row_number)].font = title_font |
|
| 667 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 668 | ws[col + str(current_row_number)] = base_period_timestamps[0][i] \ |
|
| 669 | if i < len(base_period_timestamps[0]) else None |
|
| 670 | ws[col + str(current_row_number)].border = f_border |
|
| 671 | ||
| 672 | for j in range(0, base_period_data_ca_len): |
|
| 673 | current_col_number += 1 |
|
| 674 | col = format_cell.get_column_letter(current_col_number) |
|
| 675 | ||
| 676 | ws[col + str(current_row_number)].font = title_font |
|
| 677 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 678 | ws[col + str(current_row_number)] = round(base_period_data['values_saving'][j][i], 2) \ |
|
| 679 | if i < len(base_period_data['values_saving'][j]) else None |
|
| 680 | ws[col + str(current_row_number)].border = f_border |
|
| 681 | current_col_number += 1 |
|
| 682 | col = format_cell.get_column_letter(current_col_number) |
|
| 683 | ||
| 684 | ws[col + str(current_row_number)].font = title_font |
|
| 685 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 686 | ws[col + str(current_row_number)] = reporting_period_timestamps[0][i] \ |
|
| 687 | if i < len(reporting_period_timestamps[0]) else None |
|
| 688 | ws[col + str(current_row_number)].border = f_border |
|
| 689 | ||
| 690 | for j in range(0, reporting_period_data_ca_len): |
|
| 691 | current_col_number += 1 |
|
| 692 | col = format_cell.get_column_letter(current_col_number) |
|
| 693 | ||
| 694 | ws[col + str(current_row_number)].font = title_font |
|
| 695 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 696 | ws[col + str(current_row_number)] = round(reporting_period_data['values_saving'][j][i], 2) \ |
|
| 697 | if i < len(reporting_period_data['values_saving'][j]) else None |
|
| 698 | ws[col + str(current_row_number)].border = f_border |
|
| 699 | ||
| 700 | current_row_number += 1 |
|
| 701 | ||
| 702 | current_col_number = 2 |
|
| 703 | col = format_cell.get_column_letter(current_col_number) |
|
| 704 | ws[col + str(current_row_number)].font = title_font |
|
| 705 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 706 | ws[col + str(current_row_number)] = _('Subtotal') |
|
| 707 | ws[col + str(current_row_number)].border = f_border |
|
| 708 | ||
| 709 | for i in range(0, base_period_data_ca_len): |
|
| 710 | current_col_number += 1 |
|
| 711 | col = format_cell.get_column_letter(current_col_number) |
|
| 712 | ws[col + str(current_row_number)].font = title_font |
|
| 713 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 714 | ws[col + str(current_row_number)] = round(base_period_data['subtotals_saving'][i], 2) |
|
| 715 | ws[col + str(current_row_number)].border = f_border |
|
| 716 | ||
| 717 | current_col_number += 1 |
|
| 718 | col = format_cell.get_column_letter(current_col_number) |
|
| 719 | ||
| 720 | ws[col + str(current_row_number)].font = title_font |
|
| 721 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 722 | ws[col + str(current_row_number)] = _('Subtotal') |
|
| 723 | ws[col + str(current_row_number)].border = f_border |
|
| 724 | ||
| 725 | for i in range(0, reporting_period_data_ca_len): |
|
| 726 | current_col_number += 1 |
|
| 727 | col = format_cell.get_column_letter(current_col_number) |
|
| 728 | ws[col + str(current_row_number)].font = title_font |
|
| 729 | ws[col + str(current_row_number)].alignment = c_c_alignment |
|
| 730 | ws[col + str(current_row_number)] = round(reporting_period_data['subtotals_saving'][i], 2) |
|
| 731 | ws[col + str(current_row_number)].border = f_border |
|
| 732 | ||
| 733 | for i in range(0, reporting_period_data_ca_len): |
|
| 734 | # line |
|
| 735 | line = LineChart() |
|
| 736 | line.title = _('Base Period Saving') + ' / ' \ |
|
| 737 | + _('Reporting Period Saving') + ' - ' \ |
|
| 738 | + reporting_period_data['names'][i] + " (" + reporting_period_data['units'][i] + ")" |
|
| 739 | labels = Reference(ws, min_col=2 + base_period_data_ca_len + 1, |
|
| 740 | min_row=table_start_row_number + 1, |
|
| 741 | max_row=table_start_row_number + len(reporting_period_timestamps[0])) |
|
| 742 | base_line_data = Reference(ws, min_col=3 + i, min_row=table_start_row_number, |
|
| 743 | max_row=table_start_row_number + len(reporting_period_timestamps[0])) |
|
| 744 | reporting_line_data = Reference(ws, min_col=3 + base_period_data_ca_len + 1 + i, |
|
| 745 | min_row=table_start_row_number, |
|
| 746 | max_row=table_start_row_number |
|
| 747 | + len(reporting_period_timestamps[0])) |
|
| 748 | line.add_data(base_line_data, titles_from_data=True) |
|
| 749 | line.add_data(reporting_line_data, titles_from_data=True) |
|
| 750 | line.set_categories(labels) |
|
| 751 | for j in range(len(line.series)): |
|
| 752 | line.series[j].marker.symbol = "circle" |
|
| 753 | line.series[j].smooth = True |
|
| 754 | line.x_axis.crosses = 'min' |
|
| 755 | line.height = 8.25 |
|
| 756 | line.width = 24 |
|
| 757 | line.dLbls = DataLabelList() |
|
| 758 | line.dLbls.dLblPos = 't' |
|
| 759 | line.dLbls.showVal = True |
|
| 760 | line.dLbls.showPercent = False |
|
| 761 | chart_col = 'B' |
|
| 762 | chart_cell = chart_col + str(table_start_draw_flag + 6 * i) |
|
| 763 | ws.add_chart(line, chart_cell) |
|
| 764 | ||
| 765 | current_row_number += 2 |
|
| 766 | ||
| 767 | #################################################################################################################### |
|
| 768 | if "child_space" not in report.keys() or "energy_category_names" not in report['child_space'].keys() or \ |
|