Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2989_MovingPeaksBenchmark/HeuristicLab.ExtLibs/HeuristicLab.EPPlus/4.0.3/EPPlus-4.0.3/FormulaParsing/EpplusNameValueProvider.cs @ 16605

Last change on this file since 16605 was 12074, checked in by sraggl, 10 years ago

#2341: Added EPPlus-4.0.3 to ExtLibs

File size: 1.2 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using OfficeOpenXml.FormulaParsing;
6
7namespace OfficeOpenXml.FormulaParsing
8{
9    public class EpplusNameValueProvider : INameValueProvider
10    {
11        private ExcelDataProvider _excelDataProvider;
12        private ExcelNamedRangeCollection _values;
13
14        public EpplusNameValueProvider(ExcelDataProvider excelDataProvider)
15        {
16            _excelDataProvider = excelDataProvider;
17            _values = _excelDataProvider.GetWorkbookNameValues();
18        }
19
20        public virtual bool IsNamedValue(string key, string ws)
21        {
22            if(ws!=null)
23            {
24                var wsNames = _excelDataProvider.GetWorksheetNames(ws);
25                if(wsNames!=null && wsNames.ContainsKey(key))
26                {
27                    return true;
28                }
29            }
30            return _values != null && _values.ContainsKey(key);
31        }
32
33        public virtual object GetNamedValue(string key)
34        {
35            return _values[key];
36        }
37
38        public virtual void Reload()
39        {
40            _values = _excelDataProvider.GetWorkbookNameValues();
41        }
42    }
43}
Note: See TracBrowser for help on using the repository browser.