예제 #1
0
        public RangeAddress Create(string range)
        {
            Require.That(range).Named("range").IsNotNullOrEmpty();
            //var addressInfo = ExcelAddressInfo.Parse(range);
            var adr = new ExcelAddressBase(range);

            if (adr.Table != null)
            {
                var a = _excelDataProvider.GetRange(adr.WorkSheetName, range).Address;
                //Convert the Table-style Address to an A1C1 address
                adr     = new ExcelAddressBase(a._fromRow, a._fromCol, a._toRow, a._toCol);
                adr._ws = a._ws;
            }
            var rangeAddress = new RangeAddress()
            {
                Address   = adr.Address,
                Worksheet = adr.WorkSheetName ?? "",
                FromRow   = adr._fromRow,
                FromCol   = adr._fromCol,
                ToRow     = adr._toRow,
                ToCol     = adr._toCol
            };

            //if (addressInfo.IsMultipleCells)
            //{
            //    HandleMultipleCellAddress(rangeAddress, addressInfo);
            //}
            //else
            //{
            //    HandleSingleCellAddress(rangeAddress, addressInfo);
            //}
            return(rangeAddress);
        }
예제 #2
0
        private CompileResult CompileRangeValues()
        {
            var c      = this._parsingContext.Scopes.Current;
            var result = _excelDataProvider.GetRange(c.Address.Worksheet, c.Address.FromRow, c.Address.FromCol, ExpressionString);

            if (result == null || result.IsEmpty)
            {
                return(CompileResult.Empty);
            }
            if (result.Address.Rows > 1 || result.Address.Columns > 1)
            {
                return(new CompileResult(result, DataType.Enumerable));
            }
            else
            {
                return(CompileSingleCell(result));
            }
        }
        private CompileResult CompileRangeValues()
        {
            var c      = this._parsingContext.Scopes.Current;
            var result = _excelDataProvider.GetRange(c.Address.Worksheet, c.Address.FromRow, c.Address.FromCol, ExpressionString);

            if (result == null /* || result.IsEmpty*/)
            {
                return(CompileResult.Empty);
            }
            //if (result.IsMulti)
            //{
            return(new CompileResult(result, DataType.Enumerable));
            //}
            //else
            //{
            //    return CompileSingleCell(result);
            //}
        }
예제 #4
0
        /// <summary>
        /// Compiles the expression into a value.
        /// </summary>
        /// <returns>The <see cref="CompileResult"/> with the expression value.</returns>
        public override CompileResult Compile()
        {
            var c      = this._parsingContext.Scopes.Current;
            var result = _excelDataProvider.GetRange(c.Address.Worksheet, c.Address.FromRow, c.Address.FromCol, this.ExpressionString);

            if (result == null)
            {
                var excelAddress = new ExcelAddress(this.ExpressionString);
                // External references are not supported.
                if (!string.IsNullOrEmpty(excelAddress?.Workbook))
                {
                    return(new CompileResult(eErrorType.Ref));
                }
                else
                {
                    return(CompileResult.Empty);
                }
            }
            return(this.BuildResult(result));
        }