Skip to main content

remove_redundant_implicit_intersection

Function remove_redundant_implicit_intersection 

Source
pub fn remove_redundant_implicit_intersection(node: &mut Node, add: bool)
Expand description

Inverse of add_implicit_intersection, used when exporting to Excel.

The internal (RC) representation stores every implicit intersection as @, losing the automatic flag. When exporting we must decide, for each @, whether it should be written as _xlfn.SINGLE(...) (because it is meaningful) or dropped (because add_implicit_intersection would re-insert it on import).

That decision depends on the context of the operator, exactly like add_implicit_intersection: an @ is redundant only in a position that expects a scalar (add == true). Crucially, an @ sitting in a Vector argument of a function such as SUM is not redundant: on import no automatic intersection is added there, so dropping it would change the result (e.g. SUM(A1,B1,@J:J) would become SUM(A1,B1,J:J), scanning the whole column). This pass removes only the redundant operators, leaving the rest to be stringified as _xlfn.SINGLE.

add mirrors the flag in add_implicit_intersection and must start true (a formula is evaluated in a scalar context).