Ejemplo n.º 1
0
        private static ValueEval GetValueFromArea(TwoDEval ae, int pRowIx, int pColumnIx)
        {
            Debug.Assert(pRowIx >= 0);
            Debug.Assert(pColumnIx >= 0);

            TwoDEval result = ae;

            if (pRowIx != 0)
            {
                // Slightly irregular logic for bounds checking errors
                if (pRowIx > ae.Height)
                {
                    // high bounds check fail gives #REF! if arg was explicitly passed
                    throw new EvaluationException(ErrorEval.REF_INVALID);
                }
                result = result.GetRow(pRowIx - 1);
            }

            if (pColumnIx != 0)
            {
                // Slightly irregular logic for bounds checking errors
                if (pColumnIx > ae.Width)
                {
                    // high bounds check fail gives #REF! if arg was explicitly passed
                    throw new EvaluationException(ErrorEval.REF_INVALID);
                }
                result = result.GetColumn(pColumnIx - 1);
            }
            return(result);
        }