Interface Sheet

  • All Superinterfaces:
    java.lang.Iterable<Row>
    All Known Implementing Classes:
    HSSFSheet, SXSSFSheet, XSSFChartSheet, XSSFDialogsheet, XSSFSheet

    public interface Sheet
    extends java.lang.Iterable<Row>
    High level representation of a Excel worksheet.

    Sheets are the central structures within a workbook, and are where a user does most of his spreadsheet work. The most common type of sheet is the worksheet, which is represented as a grid of cells. Worksheet cells can contain text, numbers, dates, and formulas. Cells can also be formatted.

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      int addMergedRegion​(CellRangeAddress region)
      Adds a merged region of cells (hence those cells form one)
      int addMergedRegionUnsafe​(CellRangeAddress region)
      Adds a merged region of cells (hence those cells form one).
      void addValidationData​(DataValidation dataValidation)
      Creates a data validation object
      void autoSizeColumn​(int column)
      Adjusts the column width to fit the contents.
      void autoSizeColumn​(int column, boolean useMergedCells)
      Adjusts the column width to fit the contents.
      Drawing<?> createDrawingPatriarch()
      Creates the top-level drawing patriarch.
      void createFreezePane​(int colSplit, int rowSplit)
      Creates a split (freezepane).
      void createFreezePane​(int colSplit, int rowSplit, int leftmostColumn, int topRow)
      Creates a split (freezepane).
      Row createRow​(int rownum)
      Create a new row within the sheet and return the high level representation
      void createSplitPane​(int xSplitPos, int ySplitPos, int leftmostColumn, int topRow, int activePane)
      Creates a split pane.
      CellAddress getActiveCell()
      Return location of the active cell, e.g.
      boolean getAutobreaks()
      Flag indicating whether the sheet displays Automatic Page Breaks.
      Comment getCellComment​(CellAddress ref)
      Returns cell comment for the specified location
      java.util.Map<CellAddress,​? extends Comment> getCellComments()
      Returns all cell comments on this sheet.
      int[] getColumnBreaks()
      Retrieves all the vertical page breaks
      int getColumnOutlineLevel​(int columnIndex)
      Returns the column outline level.
      CellStyle getColumnStyle​(int column)
      Returns the CellStyle that applies to the given (0 based) column, or null if no style has been set for that column
      int getColumnWidth​(int columnIndex)
      get the width (in units of 1/256th of a character width )
      float getColumnWidthInPixels​(int columnIndex)
      get the width in pixel
      DataValidationHelper getDataValidationHelper()  
      java.util.List<? extends DataValidation> getDataValidations()
      Returns the list of DataValidation in the sheet.
      int getDefaultColumnWidth()
      Get the default column width for the sheet (if the columns do not define their own width) in characters
      short getDefaultRowHeight()
      Get the default row height for the sheet (if the rows do not define their own height) in twips (1/20 of a point)
      float getDefaultRowHeightInPoints()
      Get the default row height for the sheet (if the rows do not define their own height) in points.
      boolean getDisplayGuts()
      Get whether to display the guts or not, default value is true
      Drawing<?> getDrawingPatriarch()
      Return the sheet's existing drawing, or null if there isn't yet one.
      int getFirstRowNum()
      Gets the first row on the sheet.
      boolean getFitToPage()
      Flag indicating whether the Fit to Page print option is enabled.
      Footer getFooter()
      Gets the user model for the default document footer.
      boolean getForceFormulaRecalculation()
      Whether Excel will be asked to recalculate all formulas in this sheet when the workbook is opened.
      Header getHeader()
      Gets the user model for the default document header.
      boolean getHorizontallyCenter()
      Determine whether printed output for this sheet will be horizontally centered.
      Hyperlink getHyperlink​(int row, int column)
      Get a Hyperlink in this sheet anchored at row, column
      Hyperlink getHyperlink​(CellAddress addr)
      Get a Hyperlink in this sheet located in a cell specified by {code addr}
      java.util.List<? extends Hyperlink> getHyperlinkList()
      Get a list of Hyperlinks in this sheet
      int getLastRowNum()
      Gets the last row on the sheet Note: rows which had content before and were set to empty later might still be counted as rows by Excel and Apache POI, so the result of this method will include such rows and thus the returned value might be higher than expected!
      short getLeftCol()
      The left col in the visible view when the sheet is first viewed after opening it in a viewer
      double getMargin​(short margin)
      Gets the size of the margin in inches.
      CellRangeAddress getMergedRegion​(int index)
      Returns the merged region at the specified index
      java.util.List<CellRangeAddress> getMergedRegions()
      Returns the list of merged regions.
      int getNumMergedRegions()
      Returns the number of merged regions
      PaneInformation getPaneInformation()
      Returns the information regarding the currently configured pane (split or freeze)
      int getPhysicalNumberOfRows()
      Returns the number of physically defined rows (NOT the number of rows in the sheet)
      PrintSetup getPrintSetup()
      Gets the print setup object.
      boolean getProtect()
      Answer whether protection is enabled or disabled
      CellRangeAddress getRepeatingColumns()
      Gets the repeating columns used when printing the sheet, as found in File->PageSetup->Sheet.
      CellRangeAddress getRepeatingRows()
      Gets the repeating rows used when printing the sheet, as found in File->PageSetup->Sheet.
      Row getRow​(int rownum)
      Returns the logical row (not physical) 0-based.
      int[] getRowBreaks()
      Retrieves all the horizontal page breaks
      boolean getRowSumsBelow()
      Flag indicating whether summary rows appear below detail in an outline, when applying an outline.
      boolean getRowSumsRight()
      Flag indicating whether summary columns appear to the right of detail in an outline, when applying an outline.
      boolean getScenarioProtect()
      Answer whether scenario protection is enabled or disabled
      SheetConditionalFormatting getSheetConditionalFormatting()
      The 'Conditional Formatting' facet for this Sheet
      java.lang.String getSheetName()
      Returns the name of this sheet
      short getTopRow()
      The top row in the visible view when the sheet is first viewed after opening it in a viewer
      boolean getVerticallyCenter()
      Determine whether printed output for this sheet will be vertically centered.
      Workbook getWorkbook()
      Return the parent workbook
      void groupColumn​(int fromColumn, int toColumn)
      Create an outline for the provided column range.
      void groupRow​(int fromRow, int toRow)
      Tie a range of rows together so that they can be collapsed or expanded
      boolean isColumnBroken​(int column)
      Determines if there is a page break at the indicated column
      boolean isColumnHidden​(int columnIndex)
      Get the hidden state for a given column
      boolean isDisplayFormulas()
      Returns if formulas are displayed
      boolean isDisplayGridlines()
      Returns if gridlines are displayed
      boolean isDisplayRowColHeadings()
      Returns if RowColHeadings are displayed.
      boolean isDisplayZeros()
      Gets the flag indicating whether the window should show 0 (zero) in cells containing zero value.
      boolean isPrintGridlines()
      Gets the flag indicating whether this sheet displays the lines between rows and columns to make editing and reading easier.
      boolean isPrintRowAndColumnHeadings()
      Gets the flag indicating whether this sheet prints the row and column headings when printing.
      boolean isRightToLeft()
      Whether the text is displayed in right-to-left mode in the window
      boolean isRowBroken​(int row)
      Determines if there is a page break at the indicated row
      boolean isSelected()
      Note - this is not the same as whether the sheet is focused (isActive)
      void protectSheet​(java.lang.String password)
      Sets the protection enabled as well as the password
      CellRange<? extends Cell> removeArrayFormula​(Cell cell)
      Remove a Array Formula from this sheet.
      void removeColumnBreak​(int column)
      Removes a page break at the indicated column
      void removeMergedRegion​(int index)
      Removes a merged region of cells (hence letting them free)
      void removeMergedRegions​(java.util.Collection<java.lang.Integer> indices)
      Removes a number of merged regions of cells (hence letting them free)
      void removeRow​(Row row)
      Remove a row from this sheet.
      void removeRowBreak​(int row)
      Removes the page break at the indicated row
      java.util.Iterator<Row> rowIterator()
      Returns an iterator of the physical rows
      void setActiveCell​(CellAddress address)
      Sets location of the active cell
      CellRange<? extends Cell> setArrayFormula​(java.lang.String formula, CellRangeAddress range)
      Sets array formula to specified region for result.
      void setAutobreaks​(boolean value)
      Flag indicating whether the sheet displays Automatic Page Breaks.
      AutoFilter setAutoFilter​(CellRangeAddress range)
      Enable filtering for a range of cells
      void setColumnBreak​(int column)
      Sets a page break at the indicated column.
      void setColumnGroupCollapsed​(int columnNumber, boolean collapsed)
      Expands or collapses a column group.
      void setColumnHidden​(int columnIndex, boolean hidden)
      Get the visibility state for a given column
      void setColumnWidth​(int columnIndex, int width)
      Set the width (in units of 1/256th of a character width)
      void setDefaultColumnStyle​(int column, CellStyle style)
      Sets the default column style for a given column.
      void setDefaultColumnWidth​(int width)
      Set the default column width for the sheet (if the columns do not define their own width) in characters
      void setDefaultRowHeight​(short height)
      Set the default row height for the sheet (if the rows do not define their own height) in twips (1/20 of a point)
      void setDefaultRowHeightInPoints​(float height)
      Set the default row height for the sheet (if the rows do not define their own height) in points
      void setDisplayFormulas​(boolean show)
      Sets whether the formulas are shown in a viewer
      void setDisplayGridlines​(boolean show)
      Sets whether the gridlines are shown in a viewer
      void setDisplayGuts​(boolean value)
      Set whether to display the guts or not
      void setDisplayRowColHeadings​(boolean show)
      Sets whether the RowColHeadings are shown in a viewer
      void setDisplayZeros​(boolean value)
      Set whether the window should show 0 (zero) in cells containing zero value.
      void setFitToPage​(boolean value)
      Flag indicating whether the Fit to Page print option is enabled.
      void setForceFormulaRecalculation​(boolean value)
      Control if Excel should be asked to recalculate all formulas on this sheet when the workbook is opened.
      void setHorizontallyCenter​(boolean value)
      Determines whether the output is horizontally centered on the page.
      void setMargin​(short margin, double size)
      Sets the size of the margin in inches.
      void setPrintGridlines​(boolean show)
      Sets the flag indicating whether this sheet should print the lines between rows and columns to make editing and reading easier.
      void setPrintRowAndColumnHeadings​(boolean show)
      Sets the flag indicating whether this sheet should print row and columns headings when printing.
      void setRepeatingColumns​(CellRangeAddress columnRangeRef)
      Sets the repeating columns used when printing the sheet, as found in File->PageSetup->Sheet.
      void setRepeatingRows​(CellRangeAddress rowRangeRef)
      Sets the repeating rows used when printing the sheet, as found in File->PageSetup->Sheet.
      void setRightToLeft​(boolean value)
      Sets whether the worksheet is displayed from right to left instead of from left to right.
      void setRowBreak​(int row)
      Sets a page break at the indicated row Breaks occur above the specified row and left of the specified column inclusive.
      void setRowGroupCollapsed​(int row, boolean collapse)
      Set view state of a grouped range of rows
      void setRowSumsBelow​(boolean value)
      Flag indicating whether summary rows appear below detail in an outline, when applying an outline.
      void setRowSumsRight​(boolean value)
      Flag indicating whether summary columns appear to the right of detail in an outline, when applying an outline.
      void setSelected​(boolean value)
      Sets a flag indicating whether this sheet is selected.
      void setVerticallyCenter​(boolean value)
      Determines whether the output is vertically centered on the page.
      void setZoom​(int scale)
      Window zoom magnification for current view representing percent values.
      void shiftColumns​(int startColumn, int endColumn, int n)
      Shifts columns between startColumn and endColumn, n number of columns.
      void shiftRows​(int startRow, int endRow, int n)
      Shifts rows between startRow and endRow n number of rows.
      void shiftRows​(int startRow, int endRow, int n, boolean copyRowHeight, boolean resetOriginalRowHeight)
      Shifts rows between startRow and endRow n number of rows.
      void showInPane​(int toprow, int leftcol)
      Sets desktop window pane display area, when the file is first opened in a viewer.
      void ungroupColumn​(int fromColumn, int toColumn)
      Ungroup a range of columns that were previously grouped
      void ungroupRow​(int fromRow, int toRow)
      Ungroup a range of rows that were previously grouped
      void validateMergedRegions()
      Verify that merged regions do not intersect multi-cell array formulas and no merged regions intersect another merged region in this sheet.
      • Methods inherited from interface java.lang.Iterable

        forEach, iterator, spliterator
    • Method Detail

      • createRow

        Row createRow​(int rownum)
        Create a new row within the sheet and return the high level representation
        Parameters:
        rownum - row number
        Returns:
        high level Row object representing a row in the sheet
        See Also:
        removeRow(Row)
      • removeRow

        void removeRow​(Row row)
        Remove a row from this sheet. All cells contained in the row are removed as well
        Parameters:
        row - representing a row to remove.
      • getRow

        Row getRow​(int rownum)
        Returns the logical row (not physical) 0-based. If you ask for a row that is not defined you get a null. This is to say row 4 represents the fifth row on a sheet.
        Parameters:
        rownum - row to get (0-based)
        Returns:
        Row representing the rownumber or null if its not defined on the sheet
      • getPhysicalNumberOfRows

        int getPhysicalNumberOfRows()
        Returns the number of physically defined rows (NOT the number of rows in the sheet)
        Returns:
        the number of physically defined rows in this sheet
      • getFirstRowNum

        int getFirstRowNum()
        Gets the first row on the sheet. Note: rows which had content before and were set to empty later might still be counted as rows by Excel and Apache POI, so the result of this method will include such rows and thus the returned value might be lower than expected!
        Returns:
        the number of the first logical row on the sheet (0-based)
      • getLastRowNum

        int getLastRowNum()
        Gets the last row on the sheet Note: rows which had content before and were set to empty later might still be counted as rows by Excel and Apache POI, so the result of this method will include such rows and thus the returned value might be higher than expected!
        Returns:
        last row contained on this sheet (0-based)
      • setColumnHidden

        void setColumnHidden​(int columnIndex,
                             boolean hidden)
        Get the visibility state for a given column
        Parameters:
        columnIndex - - the column to get (0-based)
        hidden - - the visibility state of the column
      • isColumnHidden

        boolean isColumnHidden​(int columnIndex)
        Get the hidden state for a given column
        Parameters:
        columnIndex - - the column to set (0-based)
        Returns:
        hidden - false if the column is visible
      • setRightToLeft

        void setRightToLeft​(boolean value)
        Sets whether the worksheet is displayed from right to left instead of from left to right.
        Parameters:
        value - true for right to left, false otherwise.
      • isRightToLeft

        boolean isRightToLeft()
        Whether the text is displayed in right-to-left mode in the window
        Returns:
        whether the text is displayed in right-to-left mode in the window
      • setColumnWidth

        void setColumnWidth​(int columnIndex,
                            int width)
        Set the width (in units of 1/256th of a character width)

        The maximum column width for an individual cell is 255 characters. This value represents the number of characters that can be displayed in a cell that is formatted with the standard font (first font in the workbook).

        Character width is defined as the maximum digit width of the numbers 0, 1, 2, ... 9 as rendered using the default font (first font in the workbook).

        Unless you are using a very special font, the default character is '0' (zero), this is true for Arial (default font font in HSSF) and Calibri (default font in XSSF)

        Please note, that the width set by this method includes 4 pixels of margin padding (two on each side), plus 1 pixel padding for the gridlines (Section 3.3.1.12 of the OOXML spec). This results is a slightly less value of visible characters than passed to this method (approx. 1/2 of a character).

        To compute the actual number of visible characters, Excel uses the following formula (Section 3.3.1.12 of the OOXML spec):

        width = Truncate([{Number of Visible Characters} * {Maximum Digit Width} + {5 pixel padding}]/{Maximum Digit Width}*256)/256 Using the Calibri font as an example, the maximum digit width of 11 point font size is 7 pixels (at 96 dpi). If you set a column width to be eight characters wide, e.g. setColumnWidth(columnIndex, 8*256), then the actual value of visible characters (the value shown in Excel) is derived from the following equation: Truncate([numChars*7+5]/7*256)/256 = 8; which gives 7.29.

        Parameters:
        columnIndex - - the column to set (0-based)
        width - - the width in units of 1/256th of a character width
        Throws:
        java.lang.IllegalArgumentException - if width > 255*256 (the maximum column width in Excel is 255 characters)
      • getColumnWidth

        int getColumnWidth​(int columnIndex)
        get the width (in units of 1/256th of a character width )

        Character width is defined as the maximum digit width of the numbers 0, 1, 2, ... 9 as rendered using the default font (first font in the workbook)

        Parameters:
        columnIndex - - the column to get (0-based)
        Returns:
        width - the width in units of 1/256th of a character width
      • getColumnWidthInPixels

        float getColumnWidthInPixels​(int columnIndex)
        get the width in pixel

        Please note, that this method works correctly only for workbooks with the default font size (Arial 10pt for .xls and Calibri 11pt for .xlsx). If the default font is changed the column width can be stretched

        Parameters:
        columnIndex - - the column to set (0-based)
        Returns:
        width in pixels
      • setDefaultColumnWidth

        void setDefaultColumnWidth​(int width)
        Set the default column width for the sheet (if the columns do not define their own width) in characters
        Parameters:
        width - default column width measured in characters
      • getDefaultColumnWidth

        int getDefaultColumnWidth()
        Get the default column width for the sheet (if the columns do not define their own width) in characters
        Returns:
        default column width measured in characters
      • getDefaultRowHeight

        short getDefaultRowHeight()
        Get the default row height for the sheet (if the rows do not define their own height) in twips (1/20 of a point)
        Returns:
        default row height measured in twips (1/20 of a point)
      • getDefaultRowHeightInPoints

        float getDefaultRowHeightInPoints()
        Get the default row height for the sheet (if the rows do not define their own height) in points.
        Returns:
        default row height in points
      • setDefaultRowHeight

        void setDefaultRowHeight​(short height)
        Set the default row height for the sheet (if the rows do not define their own height) in twips (1/20 of a point)
        Parameters:
        height - default row height measured in twips (1/20 of a point)
      • setDefaultRowHeightInPoints

        void setDefaultRowHeightInPoints​(float height)
        Set the default row height for the sheet (if the rows do not define their own height) in points
        Parameters:
        height - default row height
      • getColumnStyle

        CellStyle getColumnStyle​(int column)
        Returns the CellStyle that applies to the given (0 based) column, or null if no style has been set for that column
      • addMergedRegion

        int addMergedRegion​(CellRangeAddress region)
        Adds a merged region of cells (hence those cells form one)
        Parameters:
        region - (rowfrom/colfrom-rowto/colto) to merge
        Returns:
        index of this region
      • addMergedRegionUnsafe

        int addMergedRegionUnsafe​(CellRangeAddress region)
        Adds a merged region of cells (hence those cells form one). Skips validation. It is possible to create overlapping merged regions or create a merged region that intersects a multi-cell array formula with this formula, which may result in a corrupt workbook. To check for merged regions overlapping array formulas or other merged regions after addMergedRegionUnsafe has been called, call validateMergedRegions(), which runs in O(n^2) time.
        Parameters:
        region - to merge
        Returns:
        index of this region
        Throws:
        java.lang.IllegalArgumentException - if region contains fewer than 2 cells
      • validateMergedRegions

        void validateMergedRegions()
        Verify that merged regions do not intersect multi-cell array formulas and no merged regions intersect another merged region in this sheet.
        Throws:
        java.lang.IllegalStateException - if region intersects with a multi-cell array formula
        java.lang.IllegalStateException - if at least one region intersects with another merged region in this sheet
      • setVerticallyCenter

        void setVerticallyCenter​(boolean value)
        Determines whether the output is vertically centered on the page.
        Parameters:
        value - true to vertically center, false otherwise.
      • setHorizontallyCenter

        void setHorizontallyCenter​(boolean value)
        Determines whether the output is horizontally centered on the page.
        Parameters:
        value - true to horizontally center, false otherwise.
      • getHorizontallyCenter

        boolean getHorizontallyCenter()
        Determine whether printed output for this sheet will be horizontally centered.
      • getVerticallyCenter

        boolean getVerticallyCenter()
        Determine whether printed output for this sheet will be vertically centered.
      • removeMergedRegion

        void removeMergedRegion​(int index)
        Removes a merged region of cells (hence letting them free)
        Parameters:
        index - of the region to unmerge
      • removeMergedRegions

        void removeMergedRegions​(java.util.Collection<java.lang.Integer> indices)
        Removes a number of merged regions of cells (hence letting them free)
        Parameters:
        indices - A set of the regions to unmerge
      • getNumMergedRegions

        int getNumMergedRegions()
        Returns the number of merged regions
        Returns:
        number of merged regions
      • getMergedRegion

        CellRangeAddress getMergedRegion​(int index)
        Returns the merged region at the specified index
        Returns:
        the merged region at the specified index
      • getMergedRegions

        java.util.List<CellRangeAddress> getMergedRegions()
        Returns the list of merged regions.
        Returns:
        the list of merged regions
      • rowIterator

        java.util.Iterator<Row> rowIterator()
        Returns an iterator of the physical rows
        Returns:
        an iterator of the PHYSICAL rows. Meaning the 3rd element may not be the third row if say for instance the second row is undefined.
      • setForceFormulaRecalculation

        void setForceFormulaRecalculation​(boolean value)
        Control if Excel should be asked to recalculate all formulas on this sheet when the workbook is opened.

        Calculating the formula values with FormulaEvaluator is the recommended solution, but this may be used for certain cases where evaluation in POI is not possible.

        To force recalculation of formulas in the entire workbook use Workbook.setForceFormulaRecalculation(boolean) instead.
        Parameters:
        value - true if the application will perform a full recalculation of this worksheet values when the workbook is opened
        See Also:
        Workbook.setForceFormulaRecalculation(boolean)
      • getForceFormulaRecalculation

        boolean getForceFormulaRecalculation()
        Whether Excel will be asked to recalculate all formulas in this sheet when the workbook is opened.
      • setAutobreaks

        void setAutobreaks​(boolean value)
        Flag indicating whether the sheet displays Automatic Page Breaks.
        Parameters:
        value - true if the sheet displays Automatic Page Breaks.
      • setDisplayGuts

        void setDisplayGuts​(boolean value)
        Set whether to display the guts or not
        Parameters:
        value - - guts or no guts
      • setDisplayZeros

        void setDisplayZeros​(boolean value)
        Set whether the window should show 0 (zero) in cells containing zero value. When false, cells with zero value appear blank instead of showing the number zero.
        Parameters:
        value - whether to display or hide all zero values on the worksheet
      • isDisplayZeros

        boolean isDisplayZeros()
        Gets the flag indicating whether the window should show 0 (zero) in cells containing zero value. When false, cells with zero value appear blank instead of showing the number zero.
        Returns:
        whether all zero values on the worksheet are displayed
      • setFitToPage

        void setFitToPage​(boolean value)
        Flag indicating whether the Fit to Page print option is enabled.
        Parameters:
        value - true if the Fit to Page print option is enabled.
      • setRowSumsBelow

        void setRowSumsBelow​(boolean value)
        Flag indicating whether summary rows appear below detail in an outline, when applying an outline.

        When true a summary row is inserted below the detailed data being summarized and a new outline level is established on that row.

        When false a summary row is inserted above the detailed data being summarized and a new outline level is established on that row.

        Parameters:
        value - true if row summaries appear below detail in the outline
      • setRowSumsRight

        void setRowSumsRight​(boolean value)
        Flag indicating whether summary columns appear to the right of detail in an outline, when applying an outline.

        When true a summary column is inserted to the right of the detailed data being summarized and a new outline level is established on that column.

        When false a summary column is inserted to the left of the detailed data being summarized and a new outline level is established on that column.

        Parameters:
        value - true if col summaries appear right of the detail in the outline
      • getAutobreaks

        boolean getAutobreaks()
        Flag indicating whether the sheet displays Automatic Page Breaks.
        Returns:
        true if the sheet displays Automatic Page Breaks.
      • getDisplayGuts

        boolean getDisplayGuts()
        Get whether to display the guts or not, default value is true
        Returns:
        boolean - guts or no guts
      • getFitToPage

        boolean getFitToPage()
        Flag indicating whether the Fit to Page print option is enabled.
        Returns:
        true if the Fit to Page print option is enabled.
      • getRowSumsBelow

        boolean getRowSumsBelow()
        Flag indicating whether summary rows appear below detail in an outline, when applying an outline.

        When true a summary row is inserted below the detailed data being summarized and a new outline level is established on that row.

        When false a summary row is inserted above the detailed data being summarized and a new outline level is established on that row.

        Returns:
        true if row summaries appear below detail in the outline
      • getRowSumsRight

        boolean getRowSumsRight()
        Flag indicating whether summary columns appear to the right of detail in an outline, when applying an outline.

        When true a summary column is inserted to the right of the detailed data being summarized and a new outline level is established on that column.

        When false a summary column is inserted to the left of the detailed data being summarized and a new outline level is established on that column.

        Returns:
        true if col summaries appear right of the detail in the outline
      • isPrintGridlines

        boolean isPrintGridlines()
        Gets the flag indicating whether this sheet displays the lines between rows and columns to make editing and reading easier.
        Returns:
        true if this sheet prints gridlines.
        See Also:
        to check if gridlines are displayed on screen
      • setPrintGridlines

        void setPrintGridlines​(boolean show)
        Sets the flag indicating whether this sheet should print the lines between rows and columns to make editing and reading easier.
        Parameters:
        show - true if this sheet should print gridlines.
        See Also:
        to display gridlines on screen
      • isPrintRowAndColumnHeadings

        boolean isPrintRowAndColumnHeadings()
        Gets the flag indicating whether this sheet prints the row and column headings when printing.
        Returns:
        true if this sheet prints row and column headings.
      • setPrintRowAndColumnHeadings

        void setPrintRowAndColumnHeadings​(boolean show)
        Sets the flag indicating whether this sheet should print row and columns headings when printing.
        Parameters:
        show - true if this sheet should print row and column headings.
      • getPrintSetup

        PrintSetup getPrintSetup()
        Gets the print setup object.
        Returns:
        The user model for the print setup object.
      • getHeader

        Header getHeader()
        Gets the user model for the default document header.

        Note that XSSF offers more kinds of document headers than HSSF does

        Returns:
        the document header. Never null
      • getFooter

        Footer getFooter()
        Gets the user model for the default document footer.

        Note that XSSF offers more kinds of document footers than HSSF does.

        Returns:
        the document footer. Never null
      • setSelected

        void setSelected​(boolean value)
        Sets a flag indicating whether this sheet is selected.

        Note: multiple sheets can be selected, but only one sheet can be active at one time.

        Parameters:
        value - true if this sheet is selected
        See Also:
        Workbook.setActiveSheet(int)
      • getMargin

        double getMargin​(short margin)
        Gets the size of the margin in inches.
        Parameters:
        margin - which margin to get
        Returns:
        the size of the margin
      • setMargin

        void setMargin​(short margin,
                       double size)
        Sets the size of the margin in inches.
        Parameters:
        margin - which margin to get
        size - the size of the margin
      • getProtect

        boolean getProtect()
        Answer whether protection is enabled or disabled
        Returns:
        true => protection enabled; false => protection disabled
      • protectSheet

        void protectSheet​(java.lang.String password)
        Sets the protection enabled as well as the password
        Parameters:
        password - to set for protection. Pass null to remove protection
      • getScenarioProtect

        boolean getScenarioProtect()
        Answer whether scenario protection is enabled or disabled
        Returns:
        true => protection enabled; false => protection disabled
      • setZoom

        void setZoom​(int scale)
        Window zoom magnification for current view representing percent values. Valid values range from 10 to 400. Horizontal & Vertical scale together. For example:
         10 - 10%
         20 - 20%
         ...
         100 - 100%
         ...
         400 - 400%
         
        Parameters:
        scale - window zoom magnification
        Throws:
        java.lang.IllegalArgumentException - if scale is invalid
      • getTopRow

        short getTopRow()
        The top row in the visible view when the sheet is first viewed after opening it in a viewer
        Returns:
        short indicating the rownum (0 based) of the top row
      • getLeftCol

        short getLeftCol()
        The left col in the visible view when the sheet is first viewed after opening it in a viewer
        Returns:
        short indicating the rownum (0 based) of the top row
      • showInPane

        void showInPane​(int toprow,
                        int leftcol)
        Sets desktop window pane display area, when the file is first opened in a viewer.
        Parameters:
        toprow - the top row to show in desktop window pane
        leftcol - the left column to show in desktop window pane
      • shiftRows

        void shiftRows​(int startRow,
                       int endRow,
                       int n)
        Shifts rows between startRow and endRow n number of rows. If you use a negative number, it will shift rows up. Code ensures that rows don't wrap around. Calls shiftRows(startRow, endRow, n, false, false);

        Additionally shifts merged regions that are completely defined in these rows (ie. merged 2 cells on a row to be shifted).

        Parameters:
        startRow - the row to start shifting
        endRow - the row to end shifting
        n - the number of rows to shift
      • shiftRows

        void shiftRows​(int startRow,
                       int endRow,
                       int n,
                       boolean copyRowHeight,
                       boolean resetOriginalRowHeight)
        Shifts rows between startRow and endRow n number of rows. If you use a negative number, it will shift rows up. Code ensures that rows don't wrap around

        Additionally shifts merged regions that are completely defined in these rows (ie. merged 2 cells on a row to be shifted). All merged regions that are completely overlaid by shifting will be deleted.

        Parameters:
        startRow - the row to start shifting
        endRow - the row to end shifting
        n - the number of rows to shift
        copyRowHeight - whether to copy the row height during the shift
        resetOriginalRowHeight - whether to set the original row's height to the default
      • shiftColumns

        void shiftColumns​(int startColumn,
                          int endColumn,
                          int n)
        Shifts columns between startColumn and endColumn, n number of columns. If you use a negative number, it will shift columns left. Code ensures that columns don't wrap around
        Parameters:
        startColumn - the column to start shifting
        endColumn - the column to end shifting
        n - the number of columns to shift
      • createFreezePane

        void createFreezePane​(int colSplit,
                              int rowSplit,
                              int leftmostColumn,
                              int topRow)
        Creates a split (freezepane). Any existing freezepane or split pane is overwritten.

        If both colSplit and rowSplit are zero then the existing freeze pane is removed

        Parameters:
        colSplit - Horizontal position of split.
        rowSplit - Vertical position of split.
        leftmostColumn - Left column visible in right pane.
        topRow - Top row visible in bottom pane
      • createFreezePane

        void createFreezePane​(int colSplit,
                              int rowSplit)
        Creates a split (freezepane). Any existing freezepane or split pane is overwritten.

        If both colSplit and rowSplit are zero then the existing freeze pane is removed

        Parameters:
        colSplit - Horizontal position of split.
        rowSplit - Vertical position of split.
      • createSplitPane

        void createSplitPane​(int xSplitPos,
                             int ySplitPos,
                             int leftmostColumn,
                             int topRow,
                             int activePane)
        Creates a split pane. Any existing freezepane or split pane is overwritten.
        Parameters:
        xSplitPos - Horizontal position of split (in 1/20th of a point).
        ySplitPos - Vertical position of split (in 1/20th of a point).
        topRow - Top row visible in bottom pane
        leftmostColumn - Left column visible in right pane.
        activePane - Active pane. One of: PANE_LOWER_RIGHT, PANE_UPPER_RIGHT, PANE_LOWER_LEFT, PANE_UPPER_LEFT
        See Also:
        PANE_LOWER_LEFT, PANE_LOWER_RIGHT, PANE_UPPER_LEFT, PANE_UPPER_RIGHT
      • getPaneInformation

        PaneInformation getPaneInformation()
        Returns the information regarding the currently configured pane (split or freeze)
        Returns:
        null if no pane configured, or the pane information.
      • setDisplayGridlines

        void setDisplayGridlines​(boolean show)
        Sets whether the gridlines are shown in a viewer
        Parameters:
        show - whether to show gridlines or not
      • isDisplayGridlines

        boolean isDisplayGridlines()
        Returns if gridlines are displayed
        Returns:
        whether gridlines are displayed
      • setDisplayFormulas

        void setDisplayFormulas​(boolean show)
        Sets whether the formulas are shown in a viewer
        Parameters:
        show - whether to show formulas or not
      • isDisplayFormulas

        boolean isDisplayFormulas()
        Returns if formulas are displayed
        Returns:
        whether formulas are displayed
      • setDisplayRowColHeadings

        void setDisplayRowColHeadings​(boolean show)
        Sets whether the RowColHeadings are shown in a viewer
        Parameters:
        show - whether to show RowColHeadings or not
      • isDisplayRowColHeadings

        boolean isDisplayRowColHeadings()
        Returns if RowColHeadings are displayed.
        Returns:
        whether RowColHeadings are displayed
      • setRowBreak

        void setRowBreak​(int row)
        Sets a page break at the indicated row Breaks occur above the specified row and left of the specified column inclusive. For example, sheet.setColumnBreak(2); breaks the sheet into two parts with columns A,B,C in the first and D,E,... in the second. Similar, sheet.setRowBreak(2); breaks the sheet into two parts with first three rows (rownum=1...3) in the first part and rows starting with rownum=4 in the second.
        Parameters:
        row - the row to break, inclusive
      • isRowBroken

        boolean isRowBroken​(int row)
        Determines if there is a page break at the indicated row
        Parameters:
        row - FIXME: Document this!
        Returns:
        FIXME: Document this!
      • removeRowBreak

        void removeRowBreak​(int row)
        Removes the page break at the indicated row
        Parameters:
        row - The 0-based index of the row.
      • getRowBreaks

        int[] getRowBreaks()
        Retrieves all the horizontal page breaks
        Returns:
        all the horizontal page breaks, or null if there are no row page breaks
      • getColumnBreaks

        int[] getColumnBreaks()
        Retrieves all the vertical page breaks
        Returns:
        all the vertical page breaks, or null if there are no column page breaks
      • setColumnBreak

        void setColumnBreak​(int column)
        Sets a page break at the indicated column. Breaks occur above the specified row and left of the specified column inclusive. For example, sheet.setColumnBreak(2); breaks the sheet into two parts with columns A,B,C in the first and D,E,... in the second. Similar, sheet.setRowBreak(2); breaks the sheet into two parts with first three rows (rownum=1...3) in the first part and rows starting with rownum=4 in the second.
        Parameters:
        column - the column to break, inclusive
      • isColumnBroken

        boolean isColumnBroken​(int column)
        Determines if there is a page break at the indicated column
        Parameters:
        column - FIXME: Document this!
        Returns:
        FIXME: Document this!
      • removeColumnBreak

        void removeColumnBreak​(int column)
        Removes a page break at the indicated column
        Parameters:
        column - The 0-based index of the column.
      • setColumnGroupCollapsed

        void setColumnGroupCollapsed​(int columnNumber,
                                     boolean collapsed)
        Expands or collapses a column group.
        Parameters:
        columnNumber - One of the columns in the group.
        collapsed - true = collapse group, false = expand group.
      • groupColumn

        void groupColumn​(int fromColumn,
                         int toColumn)
        Create an outline for the provided column range.
        Parameters:
        fromColumn - beginning of the column range.
        toColumn - end of the column range.
      • ungroupColumn

        void ungroupColumn​(int fromColumn,
                           int toColumn)
        Ungroup a range of columns that were previously grouped
        Parameters:
        fromColumn - start column (0-based)
        toColumn - end column (0-based)
      • groupRow

        void groupRow​(int fromRow,
                      int toRow)
        Tie a range of rows together so that they can be collapsed or expanded
        Parameters:
        fromRow - start row (0-based)
        toRow - end row (0-based)
      • ungroupRow

        void ungroupRow​(int fromRow,
                        int toRow)
        Ungroup a range of rows that were previously grouped
        Parameters:
        fromRow - start row (0-based)
        toRow - end row (0-based)
      • setRowGroupCollapsed

        void setRowGroupCollapsed​(int row,
                                  boolean collapse)
        Set view state of a grouped range of rows
        Parameters:
        row - start row of a grouped range of rows (0-based)
        collapse - whether to expand/collapse the detail rows
      • setDefaultColumnStyle

        void setDefaultColumnStyle​(int column,
                                   CellStyle style)
        Sets the default column style for a given column. POI will only apply this style to new cells added to the sheet.
        Parameters:
        column - the column index
        style - the style to set
      • autoSizeColumn

        void autoSizeColumn​(int column)
        Adjusts the column width to fit the contents.

        This process can be relatively slow on large sheets, so this should normally only be called once per column, at the end of your processing.

        You can specify whether the content of merged cells should be considered or ignored. Default is to ignore merged cells.
        Parameters:
        column - the column index
      • autoSizeColumn

        void autoSizeColumn​(int column,
                            boolean useMergedCells)
        Adjusts the column width to fit the contents.

        This process can be relatively slow on large sheets, so this should normally only be called once per column, at the end of your processing.

        You can specify whether the content of merged cells should be considered or ignored. Default is to ignore merged cells.
        Parameters:
        column - the column index
        useMergedCells - whether to use the contents of merged cells when calculating the width of the column
      • getCellComment

        Comment getCellComment​(CellAddress ref)
        Returns cell comment for the specified location
        Returns:
        cell comment or null if not found
      • getCellComments

        java.util.Map<CellAddress,​? extends Comment> getCellComments()
        Returns all cell comments on this sheet.
        Returns:
        A map of each Comment in the sheet, keyed on the cell address where the comment is located.
      • getDrawingPatriarch

        Drawing<?> getDrawingPatriarch()
        Return the sheet's existing drawing, or null if there isn't yet one. Use createDrawingPatriarch() to get or create
        Returns:
        a SpreadsheetML drawing
      • createDrawingPatriarch

        Drawing<?> createDrawingPatriarch()
        Creates the top-level drawing patriarch.

        This may then be used to add graphics or charts.

        Note that this will normally have the effect of removing any existing drawings on this sheet.

        Returns:
        The new drawing patriarch.
      • getWorkbook

        Workbook getWorkbook()
        Return the parent workbook
        Returns:
        the parent workbook
      • getSheetName

        java.lang.String getSheetName()
        Returns the name of this sheet
        Returns:
        the name of this sheet
      • isSelected

        boolean isSelected()
        Note - this is not the same as whether the sheet is focused (isActive)
        Returns:
        true if this sheet is currently selected
      • setArrayFormula

        CellRange<? extends Cell> setArrayFormula​(java.lang.String formula,
                                                  CellRangeAddress range)
        Sets array formula to specified region for result.

        Note if there are shared formulas this will invalidate any FormulaEvaluator instances based on this workbook

        Parameters:
        formula - text representation of the formula
        range - Region of array formula for result.
        Returns:
        the CellRange of cells affected by this change
      • removeArrayFormula

        CellRange<? extends Cell> removeArrayFormula​(Cell cell)
        Remove a Array Formula from this sheet. All cells contained in the Array Formula range are removed as well
        Parameters:
        cell - any cell within Array Formula range
        Returns:
        the CellRange of cells affected by this change
      • getDataValidations

        java.util.List<? extends DataValidation> getDataValidations()
        Returns the list of DataValidation in the sheet.
        Returns:
        list of DataValidation in the sheet
      • addValidationData

        void addValidationData​(DataValidation dataValidation)
        Creates a data validation object
        Parameters:
        dataValidation - The Data validation object settings
      • setAutoFilter

        AutoFilter setAutoFilter​(CellRangeAddress range)
        Enable filtering for a range of cells
        Parameters:
        range - the range of cells to filter
      • getSheetConditionalFormatting

        SheetConditionalFormatting getSheetConditionalFormatting()
        The 'Conditional Formatting' facet for this Sheet
        Returns:
        conditional formatting rule for this sheet
      • getRepeatingRows

        CellRangeAddress getRepeatingRows()
        Gets the repeating rows used when printing the sheet, as found in File->PageSetup->Sheet.

        Repeating rows cover a range of contiguous rows, e.g.:

         Sheet1!$1:$1
         Sheet2!$5:$8
         
        The CellRangeAddress returned contains a column part which spans all columns, and a row part which specifies the contiguous range of repeating rows.

        If the Sheet does not have any repeating rows defined, null is returned.

        Returns:
        an CellRangeAddress containing the repeating rows for the Sheet, or null.
      • getRepeatingColumns

        CellRangeAddress getRepeatingColumns()
        Gets the repeating columns used when printing the sheet, as found in File->PageSetup->Sheet.

        Repeating columns cover a range of contiguous columns, e.g.:

         Sheet1!$A:$A
         Sheet2!$C:$F
         
        The CellRangeAddress returned contains a row part which spans all rows, and a column part which specifies the contiguous range of repeating columns.

        If the Sheet does not have any repeating columns defined, null is returned.

        Returns:
        an CellRangeAddress containing the repeating columns for the Sheet, or null.
      • setRepeatingRows

        void setRepeatingRows​(CellRangeAddress rowRangeRef)
        Sets the repeating rows used when printing the sheet, as found in File->PageSetup->Sheet.

        Repeating rows cover a range of contiguous rows, e.g.:

         Sheet1!$1:$1
         Sheet2!$5:$8
        The parameter CellRangeAddress should specify a column part which spans all columns, and a row part which specifies the contiguous range of repeating rows, e.g.:
         sheet.setRepeatingRows(CellRangeAddress.valueOf("2:3"));
        A null parameter value indicates that repeating rows should be removed from the Sheet:
         sheet.setRepeatingRows(null);
        Parameters:
        rowRangeRef - a CellRangeAddress containing the repeating rows for the Sheet, or null.
      • setRepeatingColumns

        void setRepeatingColumns​(CellRangeAddress columnRangeRef)
        Sets the repeating columns used when printing the sheet, as found in File->PageSetup->Sheet.

        Repeating columns cover a range of contiguous columns, e.g.:

         Sheet1!$A:$A
         Sheet2!$C:$F
        The parameter CellRangeAddress should specify a row part which spans all rows, and a column part which specifies the contiguous range of repeating columns, e.g.:
         sheet.setRepeatingColumns(CellRangeAddress.valueOf("B:C"));
        A null parameter value indicates that repeating columns should be removed from the Sheet:
         sheet.setRepeatingColumns(null);
        Parameters:
        columnRangeRef - a CellRangeAddress containing the repeating columns for the Sheet, or null.
      • getColumnOutlineLevel

        int getColumnOutlineLevel​(int columnIndex)
        Returns the column outline level. Increased as you put it into more groups (outlines), reduced as you take it out of them.
      • getHyperlink

        Hyperlink getHyperlink​(int row,
                               int column)
        Get a Hyperlink in this sheet anchored at row, column
        Parameters:
        row - The 0-based index of the row to look at.
        column - The 0-based index of the column to look at.
        Returns:
        hyperlink if there is a hyperlink anchored at row, column; otherwise returns null
      • getHyperlink

        Hyperlink getHyperlink​(CellAddress addr)
        Get a Hyperlink in this sheet located in a cell specified by {code addr}
        Parameters:
        addr - The address of the cell containing the hyperlink
        Returns:
        hyperlink if there is a hyperlink anchored at addr; otherwise returns null
        Since:
        POI 3.15 beta 3
      • getHyperlinkList

        java.util.List<? extends Hyperlink> getHyperlinkList()
        Get a list of Hyperlinks in this sheet
        Returns:
        Hyperlinks for the sheet
      • getActiveCell

        CellAddress getActiveCell()
        Return location of the active cell, e.g. A1.
        Returns:
        the location of the active cell.
        Since:
        3.14beta1
      • setActiveCell

        void setActiveCell​(CellAddress address)
        Sets location of the active cell
        Parameters:
        address - the location of the active cell, e.g. A1.
        Since:
        3.14beta1