コード例 #1
0
 public FormulaParser(ExcelDataProvider excelDataProvider, ParsingContext parsingContext)
 {
     parsingContext.Parser = this;
     parsingContext.ExcelDataProvider = excelDataProvider;
     parsingContext.NameValueProvider = new NameValueProvider(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())
             .SetIdProvider(new IntegerIdProvider())
             .FunctionRepository.LoadModule(new BuiltInFunctions());
     });
     try
     {
     var sw = new Stopwatch();
     sw.Start();
         var chain = new CalculationChain.CalculationChainBuilder(_parsingContext).Build();
         foreach (var cell in chain.Cells)
         {
             var result = ParseAt(cell.Address);
             try
             {
                 _excelDataProvider.SetCellValue(cell.Address, result);
             }
             catch { }
         }
         sw.Stop();
     }
     catch { }
 }
コード例 #2
0
 public FormulaParser(ExcelDataProvider excelDataProvider, ParsingContext parsingContext)
 {
     parsingContext.Parser              = this;
     parsingContext.ExcelDataProvider   = excelDataProvider;
     parsingContext.NameValueProvider   = new NameValueProvider(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())
         .SetIdProvider(new IntegerIdProvider())
         .FunctionRepository.LoadModule(new BuiltInFunctions());
     });
     try
     {
         var sw = new Stopwatch();
         sw.Start();
         var chain = new CalculationChain.CalculationChainBuilder(_parsingContext).Build();
         foreach (var cell in chain.Cells)
         {
             var result = ParseAt(cell.Address);
             try
             {
                 _excelDataProvider.SetCellValue(cell.Address, result);
             }
             catch { }
         }
         sw.Stop();
     }
     catch { }
 }
コード例 #3
0
 public void Setup()
 {
     _parsingContext = ParsingContext.Create();
      _excelDataProvider = MockRepository.GenerateStub<ExcelDataProvider>();
      _parsingContext.ExcelDataProvider = _excelDataProvider;
     _builder = new CalculationChainBuilder(_parsingContext);
 }