Line | |
---|
1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Linq;
|
---|
4 | using System.Text;
|
---|
5 | using OfficeOpenXml.FormulaParsing;
|
---|
6 |
|
---|
7 | namespace 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.