Calc eval fix (#272)

* ver Jun17th

updating annotations

* ver Jun17th

corrected annotation of 1d17
added check for cell merge

* ver Jun17th

updated several annotations

* ver Jun20th

fixed set-up config of 2bd59342-0664-4ccb-ba87-79379096cc08

* fix: Enhance instructions in LibreOffice Calc examples for clarity and specificity, including details on using Pivot Tables, column placements, and revenue calculations.

* ver Jun21st

updating calc evals

* ver Jun22nd

fixed an impress task

* ver Jun22ndv2

adjusted several calc tasks

* Clean scalfolds

* ver Jul18th

added two try-excepts to handle possible formula parsing and calculation
failures

---------

Co-authored-by: BowenBryanWang <bryanwang.nlp@connect.hku.hk>
Co-authored-by: yuanmengqi <yuanmengqi@mail.ustc.edu.cn>
This commit is contained in:
Danyang Zhang
2025-07-18 21:28:48 +08:00
committed by GitHub
parent 7fb1cee575
commit 53ffc05042
19 changed files with 32 additions and 22 deletions

View File

@@ -459,7 +459,11 @@ def load_xlsx_styles(xlsx_file: Workbook, sheet_name: str, book_name: str, **opt
for r in fmt.rules:
active_cells: List[Cell] = []
if r.type == "expression":
condition: Callable[[str], bool] = formula_parser.ast("=" + r.formula[0])[1].compile()
try:
condition: Callable[[str], bool] = formula_parser.ast("=" + r.formula[0])[1].compile()
except:
logger.exception("Formula parsing error: %s. Skipping.", repr(r.formula[0]))
continue
logger.debug("Expression condition: %s", r.formula[0])
arguments: List[Any] = []
@@ -493,9 +497,15 @@ def load_xlsx_styles(xlsx_file: Workbook, sheet_name: str, book_name: str, **opt
if nb_contiguous_nothings>50:
break
continue
elif condition(cell_value, *arguments):
logger.debug("Active Cell %s(%s) for %s", repr(cell), str(cell_value), r.formula[0])
active_cells.append(cell)
else:
try:
satisfies_condition: bool = condition(cell_value, *arguments)
except:
logger.exception("Error in formula calculation with cell value %d", repr(cell_value))
satisfies_condition = False
if satisfies_condition:
logger.debug("Active Cell %s(%s) for %s", repr(cell), repr(cell_value), r.formula[0])
active_cells.append(cell)
else:
raise NotImplementedError("Not Implemented Condition Type: {:}".format(r.type))

View File

@@ -82,4 +82,4 @@
"proxy": false,
"fixed_ip": false,
"possibility_of_env_change": "low"
}
}

View File

@@ -91,4 +91,4 @@
"proxy": false,
"fixed_ip": false,
"possibility_of_env_change": "low"
}
}

View File

@@ -87,4 +87,4 @@
"proxy": false,
"fixed_ip": false,
"possibility_of_env_change": "low"
}
}

View File

@@ -82,4 +82,4 @@
"proxy": false,
"fixed_ip": false,
"possibility_of_env_change": "low"
}
}

View File

@@ -109,4 +109,4 @@
"proxy": false,
"fixed_ip": false,
"possibility_of_env_change": "low"
}
}

View File

@@ -95,4 +95,4 @@
"proxy": false,
"fixed_ip": false,
"possibility_of_env_change": "low"
}
}

View File

@@ -176,4 +176,4 @@
"proxy": false,
"fixed_ip": false,
"possibility_of_env_change": "low"
}
}

View File

@@ -82,4 +82,4 @@
"proxy": false,
"fixed_ip": false,
"possibility_of_env_change": "low"
}
}

View File

@@ -32,4 +32,4 @@
"proxy": false,
"fixed_ip": false,
"possibility_of_env_change": "low"
}
}

View File

@@ -91,4 +91,4 @@
"proxy": false,
"fixed_ip": false,
"possibility_of_env_change": "low"
}
}

View File

@@ -88,4 +88,4 @@
"proxy": false,
"fixed_ip": false,
"possibility_of_env_change": "low"
}
}

View File

@@ -61,4 +61,4 @@
"proxy": false,
"fixed_ip": false,
"possibility_of_env_change": "low"
}
}

View File

@@ -82,4 +82,4 @@
"proxy": false,
"fixed_ip": false,
"possibility_of_env_change": "low"
}
}

View File

@@ -109,4 +109,4 @@
"proxy": false,
"fixed_ip": false,
"possibility_of_env_change": "low"
}
}

View File

@@ -82,4 +82,4 @@
"proxy": false,
"fixed_ip": false,
"possibility_of_env_change": "low"
}
}

View File

@@ -83,4 +83,4 @@
"proxy": false,
"fixed_ip": false,
"possibility_of_env_change": "low"
}
}

View File

@@ -112,4 +112,4 @@
"proxy": false,
"fixed_ip": false,
"possibility_of_env_change": "low"
}
}

View File

@@ -168,4 +168,4 @@
"proxy": false,
"fixed_ip": false,
"possibility_of_env_change": "low"
}
}