Esempio n. 1
0
 /// <summary>
 /// Factory method.
 /// </summary>
 /// <returns></returns>
 public static ParsingContext Create()
 {
     var context = new ParsingContext();
     context.Configuration = ParsingConfiguration.Create();
     context.Scopes = new ParsingScopes(context);
     return context;
 }
Esempio n. 2
0
 public void Initialize()
 {
     _package = new ExcelPackage();
     _provider = new EpplusExcelDataProvider(_package);
     _parsingContext = ParsingContext.Create();
     _parsingContext.Scopes.NewScope(RangeAddress.Empty);
     _worksheet = _package.Workbook.Worksheets.Add("testsheet");
 }
 public void Initialize()
 {
     _excelPackage = new ExcelPackage(new MemoryStream());
     _excelPackage.Workbook.Worksheets.Add("Test");
     _context = ParsingContext.Create();
     _context.ExcelDataProvider = new EpplusExcelDataProvider(_excelPackage);
     _context.Scopes.NewScope(RangeAddress.Empty);
 }
        public override CompileResult Execute(IEnumerable<FunctionArgument> arguments, ParsingContext context)
        {
            // Sanity check, will set excel VALUE error if min length is not met
            ValidateArguments(arguments, 1);
            // Get the first arg
            var input = ArgToString(arguments, 0);

            // return the result
            return CreateResult(input + "sh", DataType.String);
        }
 public ExcelAddressExpression(string expression, ExcelDataProvider excelDataProvider, ParsingContext parsingContext, RangeAddressFactory rangeAddressFactory, bool negate)
     : base(expression)
 {
     Require.That(excelDataProvider).Named("excelDataProvider").IsNotNull();
     Require.That(parsingContext).Named("parsingContext").IsNotNull();
     Require.That(rangeAddressFactory).Named("rangeAddressFactory").IsNotNull();
     _excelDataProvider = excelDataProvider;
     _parsingContext = parsingContext;
     _rangeAddressFactory = rangeAddressFactory;
     _negate = negate;
 }
        public override CompileResult Execute(IEnumerable<FunctionArgument> arguments, ParsingContext context)
        {
            // Sanity check, will set excel VALUE error if min length is not met
            ValidateArguments(arguments, 1);
            
            // Helper method that converts function arguments to an enumerable of doubles
            var numbers = ArgsToDoubleEnumerable(arguments, context);
            
            // Do the work
            var result = 0d;
            numbers.ToList().ForEach(x => result += (x + 2));

            // return the result
            return CreateResult(result, DataType.Decimal);
        }
Esempio n. 7
0
 public FormulaParser(ExcelDataProvider excelDataProvider, ParsingContext parsingContext)
 {
     parsingContext.Parser = this;
     parsingContext.ExcelDataProvider = excelDataProvider;
     parsingContext.NameValueProvider = new EpplusNameValueProvider(excelDataProvider);
     parsingContext.RangeAddressFactory = new RangeAddressFactory(excelDataProvider);
     _parsingContext = parsingContext;
     _excelDataProvider = excelDataProvider;
     Configure(configuration =>
     {
         configuration
             .SetLexer(new Lexer(_parsingContext.Configuration.FunctionRepository, _parsingContext.NameValueProvider))
             .SetGraphBuilder(new ExpressionGraphBuilder(excelDataProvider, _parsingContext))
             .SetExpresionCompiler(new ExpressionCompiler())
             .FunctionRepository.LoadModule(new BuiltInFunctions());
     });
 }
Esempio n. 8
0
 public FormulaParser(ExcelDataProvider excelDataProvider)
     : this(excelDataProvider, ParsingContext.Create())
 {
 }
        public override CompileResult Execute(IEnumerable<FunctionArgument> arguments, ParsingContext context)
        {
            // Sanity check, will set excel VALUE error if min length is not met
            ValidateArguments(arguments, 2);

            //Replace swedish year format with invariant for parameter 2.
            var format = arguments.ElementAt(1).Value.ToString().Replace("åååå", "yyyy");   
            var newArgs = new List<FunctionArgument> { arguments.ElementAt(0) };
            newArgs.Add(new FunctionArgument(format));

            //Use the build-in Text function.
            var func = new Text();
            return func.Execute(newArgs, context);
        }
Esempio n. 10
0
 public ExpressionFactory(ExcelDataProvider excelDataProvider, ParsingContext context)
 {
     _excelDataProvider = excelDataProvider;
     _parsingContext = context;
 }
 public void Setup()
 {
     _parsingContext = ParsingContext.Create();
     var provider = MockRepository.GenerateStub<ExcelDataProvider>();
     _factory = new ExpressionFactory(provider, _parsingContext);
 }
Esempio n. 12
0
        public ExpressionGraphBuilder(ExcelDataProvider excelDataProvider, ParsingContext parsingContext)
            : this(new ExpressionFactory(excelDataProvider, parsingContext), parsingContext)
        {

        }
Esempio n. 13
0
 public ExpressionGraphBuilder(IExpressionFactory expressionFactory, ParsingContext parsingContext)
 {
     _expressionFactory = expressionFactory;
     _parsingContext = parsingContext;
 }
Esempio n. 14
0
 public void Setup()
 {
     _context = ParsingContext.Create();
     _context.Scopes.NewScope(RangeAddress.Empty);
 }
Esempio n. 15
0
 public ExcelAddressExpression(string expression, ExcelDataProvider excelDataProvider, ParsingContext parsingContext, bool negate)
     : this(expression, excelDataProvider, parsingContext, new RangeAddressFactory(excelDataProvider), negate)
 {
 }
Esempio n. 16
0
 public void Setup()
 {
     _context = ParsingContext.Create();
 }
Esempio n. 17
0
 public void Initialize()
 {
     _parsingContext = ParsingContext.Create();
     _package = new ExcelPackage(new MemoryStream());
     _worksheet = _package.Workbook.Worksheets.Add("test");
 }
 public override CompileResult Compile(IEnumerable<Expression> children, ParsingContext context)
 {
     throw new NotImplementedException();
 }
 public override CompileResult Execute(IEnumerable<FunctionArgument> arguments, ParsingContext context)
 {
     throw new NotImplementedException();
 }
Esempio n. 20
0
 public void Initialize()
 {
     _parsingContext = ParsingContext.Create();
     _parsingContext.Scopes.NewScope(RangeAddress.Empty);
 }