Ejemplo n.º 1
0
 /**
  * Returns one column from an <c>AreaEval</c>
  *
  * @(#VALUE!) if colIndex Is negative, (#REF!) if colIndex Is too high
  */
 private ValueVector CreateResultColumnVector(AreaEval tableArray, int rowIndex)
 {
     if (rowIndex >= tableArray.Height)
     {
         throw EvaluationException.InvalidRef();
     }
     return(LookupUtils.CreateRowVector(tableArray, rowIndex));
 }
Ejemplo n.º 2
0
        public ValueEval Evaluate(ValueEval[] args, int srcCellRow, int srcCellCol)
        {
            ValueEval arg3 = null;

            switch (args.Length)
            {
            case 4:
                arg3 = args[3];     // important: assumed array element Is never null
                break;

            case 3:
                break;

            default:
                // wrong number of arguments
                return(ErrorEval.VALUE_INVALID);
            }
            try
            {
                // Evaluation order:
                // arg0 lookup_value, arg1 table_array, arg3 range_lookup, Find lookup value, arg2 row_index, fetch result
                ValueEval   lookupValue   = OperandResolver.GetSingleValue(args[0], srcCellRow, srcCellCol);
                AreaEval    tableArray    = LookupUtils.ResolveTableArrayArg(args[1]);
                bool        IsRangeLookup = LookupUtils.ResolveRangeLookupArg(arg3, srcCellRow, srcCellCol);
                int         colIndex      = LookupUtils.LookupIndexOfValue(lookupValue, LookupUtils.CreateRowVector(tableArray, 0), IsRangeLookup);
                int         rowIndex      = LookupUtils.ResolveRowOrColIndexArg(args[2], srcCellRow, srcCellCol);
                ValueVector resultCol     = CreateResultColumnVector(tableArray, rowIndex);
                return(resultCol.GetItem(colIndex));
            }
            catch (EvaluationException e)
            {
                return(e.GetErrorEval());
            }
        }