/******************************************************************************* * 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; using System.Collections.Generic; using System.Globalization; using System.Text; using System.Xml; namespace OfficeOpenXml { /// /// Access to workbook view properties /// public class ExcelWorkbookView : XmlHelper { #region ExcelWorksheetView Constructor /// /// Creates a new ExcelWorkbookView which provides access to all the /// view states of the worksheet. /// /// /// /// internal ExcelWorkbookView(XmlNamespaceManager ns, XmlNode node, ExcelWorkbook wb) : base(ns, node) { SchemaNodeOrder = wb.SchemaNodeOrder; } #endregion const string LEFT_PATH="d:bookViews/d:workbookView/@xWindow"; /// /// Position of the upper left corner of the workbook window. In twips. /// public int Left { get { return GetXmlNodeInt(LEFT_PATH); } internal set { SetXmlNodeString(LEFT_PATH,value.ToString()); } } const string TOP_PATH="d:bookViews/d:workbookView/@yWindow"; /// /// Position of the upper left corner of the workbook window. In twips. /// public int Top { get { return GetXmlNodeInt(TOP_PATH); } internal set { SetXmlNodeString(TOP_PATH, value.ToString()); } } const string WIDTH_PATH="d:bookViews/d:workbookView/@windowWidth"; /// /// Width of the workbook window. In twips. /// public int Width { get { return GetXmlNodeInt(WIDTH_PATH); } internal set { SetXmlNodeString(WIDTH_PATH, value.ToString()); } } const string HEIGHT_PATH="d:bookViews/d:workbookView/@windowHeight"; /// /// Height of the workbook window. In twips. /// public int Height { get { return GetXmlNodeInt(HEIGHT_PATH); } internal set { SetXmlNodeString(HEIGHT_PATH, value.ToString()); } } const string MINIMIZED_PATH="d:bookViews/d:workbookView/@minimized"; /// /// If true the the workbook window is minimized. /// public bool Minimized { get { return GetXmlNodeBool(MINIMIZED_PATH); } set { SetXmlNodeString(MINIMIZED_PATH, value.ToString()); } } const string SHOWVERTICALSCROLL_PATH = "d:bookViews/d:workbookView/@showVerticalScroll"; /// /// Show the vertical scrollbar /// public bool ShowVerticalScrollBar { get { return GetXmlNodeBool(SHOWVERTICALSCROLL_PATH,true); } set { SetXmlNodeBool(SHOWVERTICALSCROLL_PATH, value, true); } } const string SHOWHORIZONTALSCR_PATH = "d:bookViews/d:workbookView/@showHorizontalScroll"; /// /// Show the horizontal scrollbar /// public bool ShowHorizontalScrollBar { get { return GetXmlNodeBool(SHOWHORIZONTALSCR_PATH, true); } set { SetXmlNodeBool(SHOWHORIZONTALSCR_PATH, value, true); } } const string SHOWSHEETTABS_PATH = "d:bookViews/d:workbookView/@showSheetTabs"; /// /// Show the sheet tabs /// public bool ShowSheetTabs { get { return GetXmlNodeBool(SHOWSHEETTABS_PATH, true); } set { SetXmlNodeBool(SHOWSHEETTABS_PATH, value, true); } } /// /// Set the window position in twips /// /// /// /// /// public void SetWindowSize(int left, int top, int width, int height) { Left = left; Top = top; Width = width; Height = height; } const string ACTIVETAB_PATH = "d:bookViews/d:workbookView/@activeTab"; public int ActiveTab { get { var v=GetXmlNodeInt(ACTIVETAB_PATH); if (v < 0) return 0; else return v; } set { SetXmlNodeString(ACTIVETAB_PATH, value.ToString(CultureInfo.InvariantCulture)); } } } }