ExcelFormulaParser.Engine.Excel.Functions.RefAndLookup.LookupNavigator.GetLookupValue C# (CSharp) Method

GetLookupValue() public method

public GetLookupValue ( ) : object
return object
        public virtual object GetLookupValue()
        {
            var row = _currentRow;
            var col = _currentCol;
            if (_direction == LookupDirection.Vertical)
            {
                col += _arguments.LookupIndex - 1;
                row += _arguments.LookupOffset;
            }
            else
            {
                row += _arguments.LookupIndex - 1;
                col += _arguments.LookupOffset;
            }
            var cellValue = _parsingContext.ExcelDataProvider.GetCellValue(row, col);
            return cellValue != null ? cellValue.Value : null;
        }

Usage Example

Example #1
0
        protected CompileResult Lookup(LookupNavigator navigator, LookupArguments lookupArgs)
        {
            object lastValue       = null;
            object lastLookupValue = null;
            int?   lastMatchResult = null;

            do
            {
                var matchResult = IsMatch(navigator.CurrentValue, lookupArgs.SearchedValue);
                if (matchResult == 0)
                {
                    return(CreateResult(navigator.GetLookupValue(), DataType.String));
                }
                if (lookupArgs.RangeLookup)
                {
                    if (lastValue != null && matchResult > 0 && lastMatchResult < 0)
                    {
                        return(CreateResult(lastLookupValue, DataType.String));
                    }
                    lastMatchResult = matchResult;
                    lastValue       = navigator.CurrentValue;
                    lastLookupValue = navigator.GetLookupValue();
                }
            }while (navigator.MoveNext());

            throw new ExcelFunctionException("Lookupfunction failed to lookup value", ExcelErrorCodes.NoValueAvaliable);
        }
All Usage Examples Of ExcelFormulaParser.Engine.Excel.Functions.RefAndLookup.LookupNavigator::GetLookupValue