/** * Returns one column from an <c>AreaEval</c> * * @(#VALUE!) if colIndex Is negative, (#REF!) if colIndex Is too high */ private ValueVector CreateResultColumnVector(TwoDEval tableArray, int colIndex) { if (colIndex >= tableArray.Width) { throw EvaluationException.InvalidRef(); } return(LookupUtils.CreateColumnVector(tableArray, colIndex)); }
public override ValueEval Evaluate(int srcRowIndex, int srcColumnIndex, ValueEval arg0, ValueEval arg1, ValueEval arg2, ValueEval arg3) { try { // Evaluation order: // arg0 lookup_value, arg1 table_array, arg3 range_lookup, find lookup value, arg2 col_index, fetch result ValueEval lookupValue = OperandResolver.GetSingleValue(arg0, srcRowIndex, srcColumnIndex); TwoDEval tableArray = LookupUtils.ResolveTableArrayArg(arg1); bool isRangeLookup = LookupUtils.ResolveRangeLookupArg(arg3, srcRowIndex, srcColumnIndex); int rowIndex = LookupUtils.LookupIndexOfValue(lookupValue, LookupUtils.CreateColumnVector(tableArray, 0), isRangeLookup); int colIndex = LookupUtils.ResolveRowOrColIndexArg(arg2, srcRowIndex, srcColumnIndex); ValueVector resultCol = CreateResultColumnVector(tableArray, colIndex); return(resultCol.GetItem(rowIndex)); } catch (EvaluationException e) { return(e.GetErrorEval()); } }