1 | /*******************************************************************************
|
---|
2 | * You may amend and distribute as you like, but don't remove this header!
|
---|
3 | *
|
---|
4 | * EPPlus provides server-side generation of Excel 2007/2010 spreadsheets.
|
---|
5 | * See http://www.codeplex.com/EPPlus for details.
|
---|
6 | *
|
---|
7 | * Copyright (C) 2011 Jan Källman
|
---|
8 | *
|
---|
9 | * This library is free software; you can redistribute it and/or
|
---|
10 | * modify it under the terms of the GNU Lesser General Public
|
---|
11 | * License as published by the Free Software Foundation; either
|
---|
12 | * version 2.1 of the License, or (at your option) any later version.
|
---|
13 |
|
---|
14 | * This library is distributed in the hope that it will be useful,
|
---|
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
---|
17 | * See the GNU Lesser General Public License for more details.
|
---|
18 | *
|
---|
19 | * The GNU Lesser General Public License can be viewed at http://www.opensource.org/licenses/lgpl-license.php
|
---|
20 | * If you unfamiliar with this license or have questions about it, here is an http://www.gnu.org/licenses/gpl-faq.html
|
---|
21 | *
|
---|
22 | * All code and executables are provided "as is" with no warranty either express or implied.
|
---|
23 | * The author accepts no liability for any damage or loss of business that this product may cause.
|
---|
24 | *
|
---|
25 | * Code change notes:
|
---|
26 | *
|
---|
27 | * Author Change Date
|
---|
28 | * ******************************************************************************
|
---|
29 | * Jan Källman Added this class 2010-01-28
|
---|
30 | * Jan Källman License changed GPL-->LGPL 2011-12-27
|
---|
31 | *******************************************************************************/
|
---|
32 | using System;
|
---|
33 | using System.Collections.Generic;
|
---|
34 | using System.Text;
|
---|
35 |
|
---|
36 | namespace OfficeOpenXml
|
---|
37 | {
|
---|
38 | /// <summary>
|
---|
39 | /// A named range.
|
---|
40 | /// </summary>
|
---|
41 | public sealed class ExcelNamedRange : ExcelRangeBase
|
---|
42 | {
|
---|
43 | ExcelWorksheet _sheet;
|
---|
44 | /// <summary>
|
---|
45 | /// A named range
|
---|
46 | /// </summary>
|
---|
47 | /// <param name="name">The name</param>
|
---|
48 | /// <param name="nameSheet">The sheet containing the name. null if its a global name</param>
|
---|
49 | /// <param name="sheet">Sheet where the address points</param>
|
---|
50 | /// <param name="address">The address</param>
|
---|
51 | /// <param name="index">The index in the collection</param>
|
---|
52 | public ExcelNamedRange(string name, ExcelWorksheet nameSheet , ExcelWorksheet sheet, string address, int index) :
|
---|
53 | base(sheet, address)
|
---|
54 | {
|
---|
55 | Name = name;
|
---|
56 | _sheet = nameSheet;
|
---|
57 | Index = index;
|
---|
58 |
|
---|
59 | }
|
---|
60 | internal ExcelNamedRange(string name,ExcelWorkbook wb, ExcelWorksheet nameSheet, int index) :
|
---|
61 | base(wb, nameSheet, name, true)
|
---|
62 | {
|
---|
63 | Name = name;
|
---|
64 | _sheet = nameSheet;
|
---|
65 | Index = index;
|
---|
66 | }
|
---|
67 |
|
---|
68 | /// <summary>
|
---|
69 | /// Name of the range
|
---|
70 | /// </summary>
|
---|
71 | public string Name
|
---|
72 | {
|
---|
73 | get;
|
---|
74 | internal set;
|
---|
75 | }
|
---|
76 | /// <summary>
|
---|
77 | /// Is the named range local for the sheet
|
---|
78 | /// </summary>
|
---|
79 | public int LocalSheetId
|
---|
80 | {
|
---|
81 | get
|
---|
82 | {
|
---|
83 | if (_sheet == null)
|
---|
84 | {
|
---|
85 | return -1;
|
---|
86 | }
|
---|
87 | else
|
---|
88 | {
|
---|
89 | return _sheet.PositionID-1;
|
---|
90 | }
|
---|
91 | }
|
---|
92 | }
|
---|
93 | internal int Index
|
---|
94 | {
|
---|
95 | get;
|
---|
96 | set;
|
---|
97 | }
|
---|
98 | /// <summary>
|
---|
99 | /// Is the name hidden
|
---|
100 | /// </summary>
|
---|
101 | public bool IsNameHidden
|
---|
102 | {
|
---|
103 | get;
|
---|
104 | set;
|
---|
105 | }
|
---|
106 | /// <summary>
|
---|
107 | /// A comment for the Name
|
---|
108 | /// </summary>
|
---|
109 | public string NameComment
|
---|
110 | {
|
---|
111 | get;
|
---|
112 | set;
|
---|
113 | }
|
---|
114 | internal object NameValue { get; set; }
|
---|
115 | internal string NameFormula { get; set; }
|
---|
116 | public override string ToString()
|
---|
117 | {
|
---|
118 | return Name;
|
---|
119 | }
|
---|
120 |
|
---|
121 | }
|
---|
122 | }
|
---|