excel_utils
excel_utils
Excel file utilities for reading and writing scenario data.
Classes
ExportConfigResolver
Handles resolution of export configuration from various sources.
Functions
extract_from_main_sheet
staticmethod
Extract export config from the main sheet, skipping helper columns.
Source code in src/pyetm/utils/excel_utils.py
resolve_boolean
staticmethod
Resolve boolean value from explicit parameter, config, or default.
Source code in src/pyetm/utils/excel_utils.py
extract_from_export_config_sheet
staticmethod
Extract export configuration from a row-based EXPORT_CONFIG sheet (fields as columns, one row of values).
Source code in src/pyetm/utils/excel_utils.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | |
Functions
handle_numeric_value
handle_numeric_value(worksheet, row, col, value, cell_format=None, nan_as_formula=True, decimal_precision=10)
Handle numeric values with NaN and Inf support
Source code in src/pyetm/utils/excel_utils.py
set_column_widths
Set column widths in worksheet
Source code in src/pyetm/utils/excel_utils.py
write_index
Write pandas index to worksheet
Source code in src/pyetm/utils/excel_utils.py
create_scenario_formats
Create alternating background formats for scenario blocks
Source code in src/pyetm/utils/excel_utils.py
get_scenario_blocks
Identify scenario blocks in multi-index columns Returns list of (scenario_name, start_col, end_col) tuples
Source code in src/pyetm/utils/excel_utils.py
add_frame
add_frame(name, frame, workbook, index=True, column_width=None, index_width=None, freeze_panes=True, bold_headers=True, nan_as_formula=True, decimal_precision=10, scenario_styling=True, row_based_scenarios=False)
Add DataFrame to Excel workbook as a new worksheet with formatting.
Source code in src/pyetm/utils/excel_utils.py
381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 | |
add_series
add_series(name, series, workbook, index=True, column_width=None, index_width=None, freeze_panes=True, bold_headers=True, nan_as_formula=True, decimal_precision=10)
Add Series to Excel workbook as a new worksheet.
Source code in src/pyetm/utils/excel_utils.py
sanitize_dataframe_for_excel
Convert DataFrame to Excel-compatible format.
Source code in src/pyetm/utils/excel_utils.py
sanitize_excel_value
Convert a single value to Excel-safe format.
Source code in src/pyetm/utils/excel_utils.py
build_excel_main_dataframe
Build a MAIN sheet DataFrame for Excel export
Source code in src/pyetm/utils/excel_utils.py
apply_field_ordering
Apply preferred field ordering to DataFrame columns (for pivoted main sheet).
Source code in src/pyetm/utils/excel_utils.py
apply_scenario_column_labels
Apply human-readable labels to scenario columns.
Source code in src/pyetm/utils/excel_utils.py
build_column_rename_map
Build mapping of column IDs to human-readable labels.
Source code in src/pyetm/utils/excel_utils.py
find_matching_scenario
Find scenario matching the given column identifier.
Source code in src/pyetm/utils/excel_utils.py
get_scenario_display_label
Get display label for scenario, with fallbacks.
Source code in src/pyetm/utils/excel_utils.py
parse_excel_sheet
Safely parse an Excel sheet, returning None if it fails or doesn't exist.
Source code in src/pyetm/utils/excel_utils.py
find_first_non_empty_row
Find the first row that contains non-empty data.
Source code in src/pyetm/utils/excel_utils.py
normalize_sheet
Normalize a sheet by finding headers and cleaning data.
Source code in src/pyetm/utils/excel_utils.py
is_helper_column
Check if a column is a helper column that should be ignored.
Source code in src/pyetm/utils/excel_utils.py
extract_scenario_sheet_info
Extract sheet information for each scenario from main DataFrame.
Source code in src/pyetm/utils/excel_utils.py
extract_single_scenario_sheet_info
Extract sheet info for single scenario (Series case).
Source code in src/pyetm/utils/excel_utils.py
extract_multiple_scenario_sheet_info
Extract sheet info for multiple scenarios
Source code in src/pyetm/utils/excel_utils.py
get_safe_value
Safely get value from series with default fallback.
get_value_before_output
Get value from series, but only if it appears before 'output' section.