Skip to content

Commit 2f7347b

Browse files
Merge pull request #5 from StructuralPython/features/named_cells_ok
feature: implement ability to use named cells
2 parents 5f34f41 + 345a334 commit 2f7347b

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/xl_engine/excel_engine.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,12 @@ def excel_runner(
8686
demand_cells_to_change = {
8787
cell_id: static_inputs[cell_id][iteration]
8888
for cell_id in demand_cell_ids
89-
if valid_excel_reference(cell_id)
89+
if cell_id not in static_identifier_keys
9090
}
9191
identifier_values = {
9292
cell_id: str(static_inputs[cell_id][iteration])
9393
for cell_id in demand_cell_ids
94-
if not valid_excel_reference(cell_id)
94+
if cell_id in static_identifier_keys
9595
}
9696
if identifier_values:
9797
identifiers = "-".join([static_inputs[id_key][iteration] for id_key in static_identifier_keys])
@@ -202,14 +202,14 @@ def execute_workbook(
202202
ws = wb.sheets[sheet_idx]
203203
for cell_name, new_value in cells_to_change.items():
204204
try:
205-
ws[cell_name].value = new_value
205+
ws.range(cell_name).value = new_value
206206
except:
207207
raise ValueError(f"Invalid input cell name: {cell_name}. Perhaps you made a typo?")
208-
208+
209209
calculated_values = {} # Add afterwards
210210
for cell_to_retrieve in cells_to_retrieve:
211211
try:
212-
retrieved_value = ws[cell_to_retrieve].value
212+
retrieved_value = ws.range(cell_to_retrieve).value
213213
except:
214214
raise ValueError(f"Invalid retrieval cell name: {cell_to_retrieve}. Perhaps you made a typo?")
215215
label = cell_to_retrieve

0 commit comments

Comments
 (0)