Beispiel #1
0
 public Field(string name, Address address, Value.ValueType type = Value.ValueType.Text, Vocabulary vocabulary = null)
 {
     _name = name;
     _address = address;
     _type = type;
     _vocabulary = vocabulary;
 }
Beispiel #2
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));
        }
Beispiel #3
0
 public Range(Address initPosition, Condition finishCondition)
 {
     _initPosition = initPosition;
     _finishCondition = finishCondition;
 }