Free cookie consent management tool by TermsFeed Policy Generator

source: tags/3.3.11/HeuristicLab.ExtLibs/HeuristicLab.EPPlus/3.1.3/EPPlus-3.1.3/ExcelRow.cs @ 13398

Last change on this file since 13398 was 9580, checked in by sforsten, 11 years ago

#1730:

  • added SymbolicDataAnalysisExpressionExcelFormatter
  • changed modifiers in SymbolicExpressionTreeChart of methods SaveImageAsBitmap and SaveImageAsEmf to public
  • added menu item ExportSymbolicSolutionToExcelMenuItem to export a symbolic solution to an excel file
  • added EPPlus-3.1.3 to ExtLibs
File size: 7.7 KB
Line 
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        Initial Release           2009-10-01
30 * Jan Källman        License changed GPL-->LGPL 2011-12-27
31 *******************************************************************************/
32
33using System;
34using System.Xml;
35using OfficeOpenXml.Style;
36namespace OfficeOpenXml
37{
38  /// <summary>
39  /// Represents an individual row in the spreadsheet.
40  /// </summary>
41  public class ExcelRow : IRangeID
42  {
43    private ExcelWorksheet _worksheet;
44    private XmlElement _rowElement = null;
45        /// <summary>
46        /// Internal RowID.
47        /// </summary>
48        public ulong RowID
49        {
50            get
51            {
52                return GetRowID(_worksheet.SheetID, Row);
53            }
54        }
55    #region ExcelRow Constructor
56    /// <summary>
57    /// Creates a new instance of the ExcelRow class.
58    /// For internal use only!
59    /// </summary>
60    /// <param name="Worksheet">The parent worksheet</param>
61    /// <param name="row">The row number</param>
62    internal ExcelRow(ExcelWorksheet Worksheet, int row)
63    {
64      _worksheet = Worksheet;
65            Row = row;
66    }
67    #endregion
68
69    /// <summary>
70    /// Provides access to the node representing the row.
71    /// </summary>
72    internal XmlNode Node { get { return (_rowElement); } }
73
74    #region ExcelRow Hidden
75        bool _hidden = false;
76        /// <summary>
77    /// Allows the row to be hidden in the worksheet
78    /// </summary>
79    public bool Hidden
80        {
81            get
82            {
83                return _hidden;
84            }
85            set
86            {
87                if (_worksheet._package.DoAdjustDrawings)
88                {
89                    var pos = _worksheet.Drawings.GetDrawingHeight();
90                    _hidden = value;
91                    _worksheet.Drawings.AdjustHeight(pos);
92                }
93                else
94                {
95                    _hidden = value;
96                }
97            }
98        }       
99    #endregion
100
101    #region ExcelRow Height
102        double _height=-1;  //Set to default height
103        /// <summary>
104    /// Sets the height of the row
105    /// </summary>
106    public double Height
107        {
108      get
109      {
110                if (_height == -1)
111                {
112                    return _worksheet.DefaultRowHeight;
113                }
114                else
115                {
116                    return _height;
117                }
118                //}
119      }
120      set
121            {
122                if (_worksheet._package.DoAdjustDrawings)
123                {
124                    var pos = _worksheet.Drawings.GetDrawingWidths();
125                    _height = value;
126                    _worksheet.Drawings.AdjustHeight(pos);
127                }
128                else
129                {
130                    _height = value;
131                }
132
133                if (Hidden && value != 0)
134                {
135                    Hidden = false;
136                }
137                CustomHeight = (value != _worksheet.DefaultRowHeight);
138            }
139        }
140        /// <summary>
141        /// Set to true if You don't want the row to Autosize
142        /// </summary>
143        public bool CustomHeight { get; set; }
144    #endregion
145
146        internal string _styleName = "";
147        /// <summary>
148        /// Sets the style for the entire column using a style name.
149        /// </summary>
150        public string StyleName
151        {
152            get
153            {
154                return _styleName;
155            }
156            set
157            {
158                _styleId = _worksheet.Workbook.Styles.GetStyleIdFromName(value);
159                _styleName = value;
160            }
161        }       
162        internal int _styleId = 0;
163    /// <summary>
164    /// Sets the style for the entire row using the style ID. 
165    /// </summary>
166        public int StyleID
167    {
168      get
169      {
170        return _styleId;
171      }
172      set
173      {
174                _styleId = value;
175      }
176    }
177
178        /// <summary>
179        /// Rownumber
180        /// </summary>
181        public int Row
182        {
183            get;
184            set;
185        }
186        /// <summary>
187        /// If outline level is set this tells that the row is collapsed
188        /// </summary>
189        public bool Collapsed
190        {
191            get;
192            set;
193        }
194        /// <summary>
195        /// Outline level.
196        /// </summary>
197        public int OutlineLevel
198        {
199            get;
200            set;
201        }       
202        /// <summary>
203        /// Show phonetic Information
204        /// </summary>
205        public bool Phonetic
206        {
207            get;
208            set;
209        }
210        /// <summary>
211        /// The Style applied to the whole row. Only effekt cells with no individual style set.
212        /// Use ExcelRange object if you want to set specific styles.
213        /// </summary>
214        public ExcelStyle Style
215        {
216            get
217            {
218                return _worksheet.Workbook.Styles.GetStyleObject(StyleID,_worksheet.PositionID ,Row.ToString()+":"+Row.ToString());               
219            }
220        }
221        /// <summary>
222        /// Adds a manual page break after the row.
223        /// </summary>
224        public bool PageBreak
225        {
226            get;
227            set;
228        }
229        internal static ulong GetRowID(int sheetID, int row)
230        {
231            return ((ulong)sheetID) + (((ulong)row) << 29);
232
233        }
234
235        #region IRangeID Members
236
237        ulong IRangeID.RangeID
238        {
239            get
240            {
241                return RowID;
242            }
243            set
244            {
245                Row = ((int)(value >> 29));
246            }
247        }
248
249        #endregion
250        /// <summary>
251        /// Copies the current row to a new worksheet
252        /// </summary>
253        /// <param name="added">The worksheet where the copy will be created</param>
254        internal void Clone(ExcelWorksheet added)
255        {
256            ExcelRow newRow = added.Row(Row);
257            newRow.Collapsed = Collapsed;
258            newRow.Height = Height;
259            newRow.Hidden = Hidden;
260            newRow.OutlineLevel = OutlineLevel;
261            newRow.PageBreak = PageBreak;
262            newRow.Phonetic = Phonetic;
263            newRow.StyleName = StyleName;
264            newRow.StyleID = StyleID;
265        }
266    }
267}
Note: See TracBrowser for help on using the repository browser.