Esempio n. 1
0
        public override Value GetValue(Address address, Value.ValueType type = Value.ValueType.Text)
        {
            if (address == null || String.IsNullOrEmpty(address.Uri))
            {
                return("");
            }

            var adr = address.Uri;

            //calculate column index or RC value
            int row = _row, col = 0;

            if (Int32.TryParse(adr, out col) || CursorExcel.ParseExcelAddress(adr, ref row, ref col))
            {
                return(this.GetValue(row, col, type));
            }

            //calculate expression
            var expression = adr.StartsWith("=") ? adr.Substring(1) : adr;
            var calc       = SXExpression.Calculate(expression, _environment);

            if (calc == null || calc.Value == null)
            {
                throw new CursorException("Can't evaluate expression");
            }

            return(Value.Convert(calc.Value, type));


            //calculate expression
            //if (adr.StartsWith("=") && adr.Length > 1)
            //    return SXExpression.Calculate(adr.Substring(1), _environment);

            ////get '...' value
            //if (adr.Length >= 2 && adr.IndexOf('\'') == 0 && adr.IndexOf('\'', 1) == adr.Length - 1)
            //    return Value.Convert(adr.Substring(1, adr.Length - 2), type);

            ////get concatination ... + ... + ...
            //if (adr.Contains('+'))
            //{
            //    var parts = adr.Split(new char[] { '+' }, StringSplitOptions.RemoveEmptyEntries);
            //    return Value.Convert(String.Join("", parts.Select(part => this.GetValue(part).ToString())), type);
            //}

            //throw new CursorException(String.Format("Excel Address not recognized: {0}", adr));
        }
Esempio n. 2
0
        public override bool CheckCondition(Condition condition)
        {
            var expression = condition.Value.StartsWith("=") ? condition.Value.Substring(1) : condition.Value;

            return((SXExpression.Calculate(expression, _environment).Value as SXLexemBool).Value == SXLexemBool.BoolType.True);
        }