| /******************************************************************************* |
| * 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 2011-11-02 |
| * Jan Källman License changed GPL-->LGPL 2011-12-27 |
| *******************************************************************************/ |
| |
| using System.Collections.Immutable; |
| using System.Globalization; |
| using System.Xml; |
| |
| namespace OfficeOpenXml; |
| |
| /// <summary> |
| /// Access to workbook view properties |
| /// </summary> |
| public class ExcelWorkbookView : XmlHelper { |
| protected override ImmutableArray<string> SchemaNodeOrder => |
| ExcelWorkbook.WorkbookSchemaNodeOrder; |
| |
| /// <summary> |
| /// Creates a new ExcelWorkbookView which provides access to all the |
| /// view states of the worksheet. |
| /// </summary> |
| /// <param name="ns"></param> |
| /// <param name="node"></param> |
| /// <param name="wb"></param> |
| internal ExcelWorkbookView(XmlNamespaceManager ns, XmlNode node, ExcelWorkbook wb) |
| : base(ns, node) {} |
| |
| private const string _leftPath = "d:bookViews/d:workbookView/@xWindow"; |
| |
| /// <summary> |
| /// Position of the upper left corner of the workbook window. In twips. |
| /// </summary> |
| public int Left { |
| get => GetXmlNodeInt(_leftPath); |
| internal set => SetXmlNodeString(_leftPath, value.ToString()); |
| } |
| |
| private const string _topPath = "d:bookViews/d:workbookView/@yWindow"; |
| |
| /// <summary> |
| /// Position of the upper left corner of the workbook window. In twips. |
| /// </summary> |
| public int Top { |
| get => GetXmlNodeInt(_topPath); |
| internal set => SetXmlNodeString(_topPath, value.ToString()); |
| } |
| |
| private const string _widthPath = "d:bookViews/d:workbookView/@windowWidth"; |
| |
| /// <summary> |
| /// Width of the workbook window. In twips. |
| /// </summary> |
| public int Width { |
| get => GetXmlNodeInt(_widthPath); |
| internal set => SetXmlNodeString(_widthPath, value.ToString()); |
| } |
| |
| private const string _heightPath = "d:bookViews/d:workbookView/@windowHeight"; |
| |
| /// <summary> |
| /// Height of the workbook window. In twips. |
| /// </summary> |
| public int Height { |
| get => GetXmlNodeInt(_heightPath); |
| internal set => SetXmlNodeString(_heightPath, value.ToString()); |
| } |
| |
| private const string _minimizedPath = "d:bookViews/d:workbookView/@minimized"; |
| |
| /// <summary> |
| /// If true the the workbook window is minimized. |
| /// </summary> |
| public bool Minimized { |
| get => GetXmlNodeBool(_minimizedPath); |
| set => SetXmlNodeString(_minimizedPath, value.ToString()); |
| } |
| |
| private const string _showverticalscrollPath = "d:bookViews/d:workbookView/@showVerticalScroll"; |
| |
| /// <summary> |
| /// Show the vertical scrollbar |
| /// </summary> |
| public bool ShowVerticalScrollBar { |
| get => GetXmlNodeBool(_showverticalscrollPath, true); |
| set => SetXmlNodeBool(_showverticalscrollPath, value, true); |
| } |
| |
| private const string _showhorizontalscrPath = "d:bookViews/d:workbookView/@showHorizontalScroll"; |
| |
| /// <summary> |
| /// Show the horizontal scrollbar |
| /// </summary> |
| public bool ShowHorizontalScrollBar { |
| get => GetXmlNodeBool(_showhorizontalscrPath, true); |
| set => SetXmlNodeBool(_showhorizontalscrPath, value, true); |
| } |
| |
| private const string _showsheettabsPath = "d:bookViews/d:workbookView/@showSheetTabs"; |
| |
| /// <summary> |
| /// Show the sheet tabs |
| /// </summary> |
| public bool ShowSheetTabs { |
| get => GetXmlNodeBool(_showsheettabsPath, true); |
| set => SetXmlNodeBool(_showsheettabsPath, value, true); |
| } |
| |
| /// <summary> |
| /// Set the window position in twips |
| /// </summary> |
| /// <param name="left"></param> |
| /// <param name="top"></param> |
| /// <param name="width"></param> |
| /// <param name="height"></param> |
| public void SetWindowSize(int left, int top, int width, int height) { |
| Left = left; |
| Top = top; |
| Width = width; |
| Height = height; |
| } |
| |
| private const string _activetabPath = "d:bookViews/d:workbookView/@activeTab"; |
| |
| public int ActiveTab { |
| get { |
| var v = GetXmlNodeInt(_activetabPath); |
| if (v < 0) { |
| return 0; |
| } |
| return v; |
| } |
| set => SetXmlNodeString(_activetabPath, value.ToString(CultureInfo.InvariantCulture)); |
| } |
| } |