| /******************************************************************************* |
| * You may amend and distribute as you like, but don't remove this header! |
| * |
| * EPPlus provides server-side generation of Excel 2007/2010 spreadsheets. |
| * See http://www.codeplex.com/EPPlus for details. |
| * |
| * Copyright (C) 2011 Jan Källman |
| * |
| * This library is free software; you can redistribute it and/or |
| * modify it under the terms of the GNU Lesser General Public |
| * License as published by the Free Software Foundation; either |
| * version 2.1 of the License, or (at your option) any later version. |
| |
| * This library is distributed in the hope that it will be useful, |
| * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| * See the GNU Lesser General Public License for more details. |
| * |
| * The GNU Lesser General Public License can be viewed at http://www.opensource.org/licenses/lgpl-license.php |
| * If you unfamiliar with this license or have questions about it, here is an http://www.gnu.org/licenses/gpl-faq.html |
| * |
| * All code and executables are provided "as is" with no warranty either express or implied. |
| * The author accepts no liability for any damage or loss of business that this product may cause. |
| * |
| * Code change notes: |
| * |
| * Author Change Date |
| * ****************************************************************************** |
| * Jan Källman Initial Release 2009-10-01 |
| * Jan Källman License changed GPL-->LGPL 2011-12-16 |
| *******************************************************************************/ |
| |
| using OfficeOpenXml.Style.XmlAccess; |
| |
| namespace OfficeOpenXml.Style; |
| |
| /// <summary> |
| /// Toplevel class for cell styling |
| /// </summary> |
| public sealed class ExcelStyle : StyleBase { |
| internal ExcelStyle( |
| ExcelStyles styles, |
| XmlHelper.ChangedEventHandler changedEvent, |
| int positionId, |
| string address, |
| int xfsId) |
| : base(styles, changedEvent, positionId, address) { |
| Index = xfsId; |
| ExcelXfs xfs; |
| if (positionId > -1) { |
| xfs = _styles.CellXfs[xfsId]; |
| } else { |
| xfs = _styles.CellStyleXfs[xfsId]; |
| } |
| Styles = styles; |
| PositionID = positionId; |
| Numberformat = new(styles, changedEvent, PositionID, address, xfs.NumberFormatId); |
| Font = new(styles, changedEvent, PositionID, address, xfs.FontId); |
| Fill = new(styles, changedEvent, PositionID, address, xfs.FillId); |
| Border = new(styles, changedEvent, PositionID, address, xfs.BorderId); |
| } |
| |
| /// <summary> |
| /// Numberformat |
| /// </summary> |
| public ExcelNumberFormat Numberformat { get; set; } |
| |
| /// <summary> |
| /// Font styling |
| /// </summary> |
| public ExcelFont Font { get; set; } |
| |
| /// <summary> |
| /// Fill Styling |
| /// </summary> |
| public ExcelFill Fill { get; set; } |
| |
| /// <summary> |
| /// Border |
| /// </summary> |
| public Border Border { get; set; } |
| |
| /// <summary> |
| /// The horizontal alignment in the cell |
| /// </summary> |
| public ExcelHorizontalAlignment HorizontalAlignment => _styles.CellXfs[Index].HorizontalAlignment; |
| |
| /// <summary> |
| /// The vertical alignment in the cell |
| /// </summary> |
| public ExcelVerticalAlignment VerticalAlignment => _styles.CellXfs[Index].VerticalAlignment; |
| |
| /// <summary> |
| /// Wrap the text |
| /// </summary> |
| public bool WrapText { |
| get => _styles.CellXfs[Index].WrapText; |
| set => |
| _ChangedEvent( |
| this, |
| new(eStyleClass.Style, eStyleProperty.WrapText, value, _positionID, _address)); |
| } |
| |
| /// <summary> |
| /// Readingorder |
| /// </summary> |
| public ExcelReadingOrder ReadingOrder => _styles.CellXfs[Index].ReadingOrder; |
| |
| /// <summary> |
| /// Shrink the text to fit |
| /// </summary> |
| public bool ShrinkToFit => _styles.CellXfs[Index].ShrinkToFit; |
| |
| /// <summary> |
| /// The margin between the border and the text |
| /// </summary> |
| public int Indent => _styles.CellXfs[Index].Indent; |
| |
| /// <summary> |
| /// Text orientation in degrees. Values range from 0 to 180. |
| /// </summary> |
| public int TextRotation => _styles.CellXfs[Index].TextRotation; |
| |
| /// <summary> |
| /// If true the cell is locked for editing when the sheet is protected |
| /// <seealso cref="ExcelWorksheet.Protection"/> |
| /// </summary> |
| public bool Locked => _styles.CellXfs[Index].Locked; |
| |
| /// <summary> |
| /// If true the formula is hidden when the sheet is protected. |
| /// <seealso cref="ExcelWorksheet.Protection"/> |
| /// </summary> |
| public bool Hidden => _styles.CellXfs[Index].Hidden; |
| |
| /// <summary> |
| /// The index in the style collection |
| /// </summary> |
| public int XfId => _styles.CellXfs[Index].XfId; |
| |
| internal int PositionID { get; set; } |
| |
| internal ExcelStyles Styles { get; set; } |
| |
| internal override string Id => |
| Numberformat.Id |
| + "|" |
| + Font.Id |
| + "|" |
| + Fill.Id |
| + "|" |
| + Border.Id |
| + "|" |
| + VerticalAlignment |
| + "|" |
| + HorizontalAlignment |
| + "|" |
| + WrapText |
| + "|" |
| + ReadingOrder |
| + "|" |
| + XfId; |
| } |