[9580] | 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 | public ExcelNamedRange(string name, ExcelWorksheet nameSheet , ExcelWorksheet sheet, string address) :
|
---|
| 52 | base(sheet, address)
|
---|
| 53 | {
|
---|
| 54 | Name = name;
|
---|
| 55 | _sheet = nameSheet;
|
---|
| 56 |
|
---|
| 57 | }
|
---|
| 58 | internal ExcelNamedRange(string name,ExcelWorkbook wb, ExcelWorksheet nameSheet) :
|
---|
| 59 | base(wb, nameSheet, name, true)
|
---|
| 60 | {
|
---|
| 61 | Name = name;
|
---|
| 62 | _sheet = nameSheet;
|
---|
| 63 | }
|
---|
| 64 |
|
---|
| 65 | /// <summary>
|
---|
| 66 | /// Name of the range
|
---|
| 67 | /// </summary>
|
---|
| 68 | public string Name
|
---|
| 69 | {
|
---|
| 70 | get;
|
---|
| 71 | internal set;
|
---|
| 72 | }
|
---|
| 73 | /// <summary>
|
---|
| 74 | /// Is the named range local for the sheet
|
---|
| 75 | /// </summary>
|
---|
| 76 | public int LocalSheetId
|
---|
| 77 | {
|
---|
| 78 | get
|
---|
| 79 | {
|
---|
| 80 | if (_sheet == null)
|
---|
| 81 | {
|
---|
| 82 | return -1;
|
---|
| 83 | }
|
---|
| 84 | else
|
---|
| 85 | {
|
---|
| 86 | return _sheet.PositionID-1;
|
---|
| 87 | }
|
---|
| 88 | }
|
---|
| 89 | }
|
---|
| 90 | /// <summary>
|
---|
| 91 | /// Is the name hidden
|
---|
| 92 | /// </summary>
|
---|
| 93 | public bool IsNameHidden
|
---|
| 94 | {
|
---|
| 95 | get;
|
---|
| 96 | set;
|
---|
| 97 | }
|
---|
| 98 | /// <summary>
|
---|
| 99 | /// A comment for the Name
|
---|
| 100 | /// </summary>
|
---|
| 101 | public string NameComment
|
---|
| 102 | {
|
---|
| 103 | get;
|
---|
| 104 | set;
|
---|
| 105 | }
|
---|
| 106 | internal object NameValue { get; set; }
|
---|
| 107 | internal string NameFormula { get; set; }
|
---|
| 108 | public override string ToString()
|
---|
| 109 | {
|
---|
| 110 | return Name;
|
---|
| 111 | }
|
---|
| 112 | }
|
---|
| 113 | }
|
---|