/* ==================================================================== Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for Additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ namespace HH.WMS.Utils.NPOI.SS.UserModel { using System; using System.Collections; using System.IO; using HH.WMS.Utils.NPOI.SS.Formula.Udf; public enum SheetState : int { /// /// Indicates the sheet is visible. /// VISIBLE = 0, /// /// Indicates the book window is hidden, but can be shown by the user via the user interface. /// HIDDEN = 1, /// /// Indicates the sheet is hidden and cannot be shown in the user interface (UI). /// /// /// In Excel this state is only available programmatically in VBA: /// ThisWorkbook.Sheets("MySheetName").Visible = xlSheetVeryHidden /// /// VERY_HIDDEN = 2 } /// /// High level interface of a Excel workbook. This is the first object most users /// will construct whether they are reading or writing a workbook. It is also the /// top level object for creating new sheets/etc. /// This interface is shared between the implementation specific to xls and xlsx. /// This way it is possible to access Excel workbooks stored in both formats. /// public interface IWorkbook { /// /// get the active sheet. The active sheet is is the sheet /// which is currently displayed when the workbook is viewed in Excel. /// int ActiveSheetIndex { get; } /// /// Gets the first tab that is displayed in the list of tabs in excel. /// int FirstVisibleTab { get; set; } /// /// Sets the order of appearance for a given sheet. /// /// the name of the sheet to reorder /// the position that we want to insert the sheet into (0 based) void SetSheetOrder(String sheetname, int pos); /// /// Sets the tab whose data is actually seen when the sheet is opened. /// This may be different from the "selected sheet" since excel seems to /// allow you to show the data of one sheet when another is seen "selected" /// in the tabs (at the bottom). /// /// the index of the sheet to select (0 based) void SetSelectedTab(int index); /// /// set the active sheet. The active sheet is is the sheet /// which is currently displayed when the workbook is viewed in Excel. /// /// index of the active sheet (0-based) void SetActiveSheet(int sheetIndex); /// /// Set the sheet name /// /// sheet number (0 based) /// Sheet name String GetSheetName(int sheet); /// /// Set the sheet name. /// /// sheet number (0 based) /// sheet name void SetSheetName(int sheet, String name); /// /// Returns the index of the sheet by its name /// /// the sheet name /// index of the sheet (0 based) int GetSheetIndex(String name); /// /// Returns the index of the given sheet /// /// the sheet to look up /// index of the sheet (0 based) int GetSheetIndex(ISheet sheet); /// /// Sreate an Sheet for this Workbook, Adds it to the sheets and returns /// the high level representation. Use this to create new sheets. /// /// ISheet CreateSheet(); /// /// Create an Sheet for this Workbook, Adds it to the sheets and returns /// the high level representation. Use this to create new sheets. /// /// sheetname to set for the sheet. /// Sheet representing the new sheet. ISheet CreateSheet(String sheetname); /// /// Create an Sheet from an existing sheet in the Workbook. /// /// /// ISheet CloneSheet(int sheetNum); /// /// Get the number of spreadsheets in the workbook /// int NumberOfSheets { get; } /// /// Get the Sheet object at the given index. /// /// index of the sheet number (0-based physical & logical) /// Sheet at the provided index ISheet GetSheetAt(int index); /// /// Get sheet with the given name /// /// name of the sheet /// Sheet with the name provided or null if it does not exist ISheet GetSheet(String name); /// /// Support foreach ISheet, e.g. /// HSSFWorkbook workbook = new HSSFWorkbook(); /// foreach(ISheet sheet in workbook) ... /// /// Enumeration of all the sheets of this workbook IEnumerator GetEnumerator(); /// /// Removes sheet at the given index /// /// void RemoveSheetAt(int index); /** * To set just repeating columns: * workbook.SetRepeatingRowsAndColumns(0,0,1,-1-1); * To set just repeating rows: * workbook.SetRepeatingRowsAndColumns(0,-1,-1,0,4); * To remove all repeating rows and columns for a sheet. * workbook.SetRepeatingRowsAndColumns(0,-1,-1,-1,-1); */ /// /// Sets the repeating rows and columns for a sheet (as found in /// File->PageSetup->Sheet). This is function is included in the workbook /// because it Creates/modifies name records which are stored at the /// workbook level. /// /// 0 based index to sheet. /// 0 based start of repeating columns. /// 0 based end of repeating columns. /// 0 based start of repeating rows. /// 0 based end of repeating rows. void SetRepeatingRowsAndColumns(int sheetIndex, int startColumn, int endColumn, int startRow, int endRow); /// /// Create a new Font and add it to the workbook's font table /// /// IFont CreateFont(); /// /// Finds a font that matches the one with the supplied attributes /// /// /// /// /// /// /// /// /// /// the font with the matched attributes or null IFont FindFont(short boldWeight, short color, short fontHeight, String name, bool italic, bool strikeout, short typeOffset, byte underline); /// /// Get the number of fonts in the font table /// short NumberOfFonts { get; } /// /// Get the font at the given index number /// /// index number (0-based) /// font at the index IFont GetFontAt(short idx); /// /// Create a new Cell style and add it to the workbook's style table /// /// the new Cell Style object ICellStyle CreateCellStyle(); /// /// Get the number of styles the workbook Contains /// short NumCellStyles { get; } /// /// Get the cell style object at the given index /// /// index within the set of styles (0-based) /// CellStyle object at the index ICellStyle GetCellStyleAt(short idx); /// /// Write out this workbook to an OutPutstream. /// /// the stream you wish to write to void Write(Stream stream); /// /// the total number of defined names in this workbook /// int NumberOfNames { get; } /// /// the defined name with the specified name. /// /// the name of the defined name /// the defined name with the specified name. null if not found IName GetName(String name); /// /// the defined name at the specified index /// /// position of the named range (0-based) /// IName GetNameAt(int nameIndex); /// /// Creates a new (unInitialised) defined name in this workbook /// /// new defined name object IName CreateName(); /// /// Gets the defined name index by name /// /// the name of the defined name /// zero based index of the defined name. int GetNameIndex(String name); /// /// Remove the defined name at the specified index /// /// named range index (0 based) void RemoveName(int index); /// /// Remove a defined name by name /// /// the name of the defined name void RemoveName(String name); /// /// Sets the printarea for the sheet provided /// /// Zero-based sheet index /// Valid name Reference for the Print Area void SetPrintArea(int sheetIndex, String reference); /// /// Sets the printarea for the sheet provided /// /// Zero-based sheet index (0 = First Sheet) /// Column to begin printarea /// Column to end the printarea /// Row to begin the printarea /// Row to end the printarea void SetPrintArea(int sheetIndex, int startColumn, int endColumn, int startRow, int endRow); /// /// Retrieves the reference for the printarea of the specified sheet, /// the sheet name is Appended to the reference even if it was not specified. /// /// Zero-based sheet index /// Null if no print area has been defined String GetPrintArea(int sheetIndex); /// /// Delete the printarea for the sheet specified /// /// Zero-based sheet index (0 = First Sheet) void RemovePrintArea(int sheetIndex); /// /// Retrieves the current policy on what to do when getting missing or blank cells from a row. /// MissingCellPolicy MissingCellPolicy { get; set; } /// /// Returns the instance of DataFormat for this workbook. /// /// the DataFormat object IDataFormat CreateDataFormat(); /// /// Adds a picture to the workbook. /// /// The bytes of the picture /// The format of the picture. /// the index to this picture (1 based). int AddPicture(byte[] pictureData, PictureType format); /// /// Gets all pictures from the Workbook. /// /// the list of pictures (a list of link PictureData objects.) IList GetAllPictures(); /// /// Return an object that handles instantiating concrete classes of /// the various instances one needs for HSSF and XSSF. /// /// ICreationHelper GetCreationHelper(); /// /// if this workbook is not visible in the GUI /// bool IsHidden { get; set; } /// /// Check whether a sheet is hidden. /// /// number of sheet /// true if sheet is hidden bool IsSheetHidden(int sheetIx); /** * Check whether a sheet is very hidden. *

* This is different from the normal hidden status * ({@link #isSheetHidden(int)}) *

* @param sheetIx sheet index to check * @return true if sheet is very hidden */ bool IsSheetVeryHidden(int sheetIx); /** * Hide or unhide a sheet * * @param sheetIx the sheet index (0-based) * @param hidden True to mark the sheet as hidden, false otherwise */ void SetSheetHidden(int sheetIx, SheetState hidden); /** * Hide or unhide a sheet. *
         *  0 = not hidden
         *  1 = hidden
         *  2 = very hidden.
         * 
* @param sheetIx The sheet number * @param hidden 0 for not hidden, 1 for hidden, 2 for very hidden */ void SetSheetHidden(int sheetIx, int hidden); /// /// Register a new toolpack in this workbook. /// /// the toolpack to register void AddToolPack(UDFFinder toopack); } }