Interface SSheet

All Known Implementing Classes:
AbstractSheetAdv, SheetImpl

public interface SSheet
A sheet of a book. It's the main class you can manipulate rows, columns, cells, pictures, charts, and data validation.
Since:
3.5.0
Author:
dennis
  • Method Details

    • getBook

      SBook getBook()
      Get the owner book
      Returns:
      the owner book
    • getSheetName

      String getSheetName()
      Get the sheet name
      Returns:
      the sheet name
    • getRowIterator

      Iterator<SRow> getRowIterator()
      Returns:
      an iterator of existing rows excluding those blank rows
    • getRowIterator

      Iterator<SRow> getRowIterator(int start, int end)
      Parameters:
      start - the start index
      end - the end index
      Returns:
      an iterator of existing rows excluding those blank rows
      Since:
      5.0.0
    • getColumnIterator

      Iterator<SColumn> getColumnIterator()
      Returns:
      an iterator of existing columns excluding those blank columns
    • getColumnArrayIterator

      Iterator<SColumnArray> getColumnArrayIterator()
    • setupColumnArray

      SColumnArray setupColumnArray(int colunmIdx, int lastColumnIdx)
      Set up a column array, if one array range overlaps another, it throws IllegalStateException. If you setup a column array that is not continuous, (for example, 0~2, 5~6), then it will create a missing column array automatically to make them continuous.(3~4 in the example). It's required to set up in ascending order of starting column index (min), or it will create unexpected SColumnArray for columns are not continuous.
      Parameters:
      colunmIdx - index of the starting column
      lastColumnIdx - index of the end column
      Returns:
      the new created column array
    • getCellIterator

      Iterator<SCell> getCellIterator(int row)
    • getDefaultRowHeight

      int getDefaultRowHeight()
      Returns:
      default row height in pixels
    • getDefaultColumnWidth

      int getDefaultColumnWidth()
      Returns:
      default column width in pixels
    • setDefaultRowHeight

      void setDefaultRowHeight(int height)
      set default row height in pixels
    • setDefaultColumnWidth

      void setDefaultColumnWidth(int width)
      set default column width in pixels
    • getRow

      SRow getRow(int rowIdx)
    • getColumnArray

      SColumnArray getColumnArray(int columnIdx)
      See Also:
    • getColumn

      SColumn getColumn(int columnIdx)
    • getCell

      SCell getCell(int rowIdx, int columnIdx)
      This method always returns not-null cell object. Use SCell.isNull() to know it's null (blank) or not.
    • getCell

      SCell getCell(String cellRefString)
      Returns:
      return a cell with specified cell reference, e.g. A2, B3. Area reference, A1:A2, is not acceptable.
      See Also:
    • getId

      String getId()
      Returns:
      interal sheet object ID
    • getViewInfo

      SSheetViewInfo getViewInfo()
    • getPrintSetup

      SPrintSetup getPrintSetup()
    • getStartRowIndex

      int getStartRowIndex()
    • getEndRowIndex

      int getEndRowIndex()
    • getStartColumnIndex

      int getStartColumnIndex()
    • getEndColumnIndex

      int getEndColumnIndex()
    • getStartCellIndex

      int getStartCellIndex(int rowIdx)
    • getEndCellIndex

      int getEndCellIndex(int rowIdx)
    • clearCell

      void clearCell(int rowIdx, int columnIdx, int lastRowIdx, int lastColumnIdx)
      See Also:
    • clearCell

      void clearCell(CellRegion region)
      Clear cells in specified region
    • moveCell

      void moveCell(int rowIdx, int columnIdx, int lastRowIdx, int lastColumnIdx, int rowOffset, int columnOffset)
      Move a region of cells specified by 4 indexes.
      See Also:
    • moveCell

      void moveCell(CellRegion region, int rowOffset, int columnOffset)
      Move one or more cells.
      Parameters:
      region - the region of cells to move
      rowOffset - positive number to move down, negative to move up
      columnOffset - positive number to move right, negative to move left
    • insertRow

      void insertRow(int rowIdx, int lastRowIdx)
      insert rows specified by first and last index
    • deleteRow

      void deleteRow(int rowIdx, int lastRowIdx)
      delete rows specified by first and last index
    • insertColumn

      void insertColumn(int columnIdx, int lastColumnIdx)
      insert columns specified by first and last index
    • deleteColumn

      void deleteColumn(int columnIdx, int lastColumnIdx)
      delete columns specified by first and last index
    • insertCell

      void insertCell(int rowIdx, int columnIdx, int lastRowIndex, int lastColumnIndex, boolean horizontal)
      See Also:
    • insertCell

      void insertCell(CellRegion region, boolean horizontal)
      Insert a region of cells and shift existing cells.
      Parameters:
      region - the region of cells to insert
      horizontal - TRUE for shifting right, FALSE for shifting down
    • deleteCell

      void deleteCell(CellRegion region, boolean horizontal)
      Delete a region of cells and shift existing cells.
      Parameters:
      region - the region of cells to delete
      horizontal - TRUE for shifting left, FALSE for shifting up
    • deleteCell

      void deleteCell(int rowIdx, int columnIdx, int lastRowIndex, int lastColumnIndex, boolean horizontal)
      See Also:
    • addPicture

      SPicture addPicture(SPicture.Format format, byte[] data, ViewAnchor anchor)
      Add a picture into this sheet with raw picture data and format.
      Parameters:
      format - picture format as specified in SPicture.Format
      data - raw byte data of the picture
      anchor - where to anchor this picture
      Returns:
      the added SPicture
    • addPicture

      SPicture addPicture(int index, ViewAnchor anchor)
      Add a picture into the sheet with known picture data index.
      Parameters:
      index - SPictureData index
      anchor - where to anchor this picture
      Returns:
      the SPicture added
      Since:
      3.6.0
    • getPicture

      SPicture getPicture(String picid)
    • deletePicture

      void deletePicture(SPicture picture)
    • getNumOfPicture

      int getNumOfPicture()
    • getPicture

      SPicture getPicture(int idx)
    • getPictures

      List<SPicture> getPictures()
    • addChart

      SChart addChart(SChart.ChartType type, ViewAnchor anchor)
    • getChart

      SChart getChart(String chartid)
    • deleteChart

      void deleteChart(SChart chart)
    • getNumOfChart

      int getNumOfChart()
    • getChart

      SChart getChart(int idx)
    • getCharts

      List<SChart> getCharts()
    • getMergedRegions

      List<CellRegion> getMergedRegions()
    • removeMergedRegion

      void removeMergedRegion(CellRegion region, boolean removeOverlaps)
      Remove the merged area that are contained by region
      Parameters:
      region -
      removeOverlaps - true if you want to remove the merged areas that are just overlapped.
    • addMergedRegion

      void addMergedRegion(CellRegion region)
      Add a merged area, you can't assign a area that overlaps existed merged area.
      Parameters:
      region -
    • getNumOfMergedRegion

      int getNumOfMergedRegion()
    • getMergedRegion

      CellRegion getMergedRegion(int idx)
    • getOverlapsMergedRegions

      List<CellRegion> getOverlapsMergedRegions(CellRegion region, boolean excludeContains)
      Get the merged region that overlapped the region
      Returns:
      the regions that overlaps
    • getContainsMergedRegions

      List<CellRegion> getContainsMergedRegions(CellRegion region)
      Get the merged region that are contained by region.
      Returns:
      the regions that are contained
    • getMergedRegion

      CellRegion getMergedRegion(int row, int column)
    • getMergedRegion

      CellRegion getMergedRegion(String cellRefString)
    • addDataValidation

      SDataValidation addDataValidation(CellRegion region)
    • addDataValidation

      SDataValidation addDataValidation(CellRegion region, SDataValidation src)
    • getDataValidation

      SDataValidation getDataValidation(String id)
    • deleteDataValidation

      void deleteDataValidation(SDataValidation validation)
    • getNumOfDataValidation

      int getNumOfDataValidation()
    • getDataValidation

      SDataValidation getDataValidation(int idx)
    • getDataValidations

      List<SDataValidation> getDataValidations()
    • deleteDataValidationRegion

      List<SDataValidation> deleteDataValidationRegion(CellRegion region)
      Delete data validations that are covered by the specified region.
      Parameters:
      region - the cover region
      Returns:
      the data validations deleted
      Since:
      3.6.0
    • getDataValidation

      SDataValidation getDataValidation(int row, int column)
      Parameters:
      row -
      column -
      Returns:
      the first data validation at row, column
    • getAttribute

      Object getAttribute(String name)
      Get the runtime custom attribute that stored in this sheet
      Parameters:
      name - the attribute name
      Returns:
      the value, or null if not found
    • setAttribute

      Object setAttribute(String name, Object value)
      Set the runtime custom attribute to stored in this sheet, the attribute is only use for developer to stored runtime data in the sheet, values will not stored to excel when exporting.
      Parameters:
      name - name the attribute name
      value - the attribute value
    • getAttributes

      Map<String,Object> getAttributes()
      Get the unmodifiable runtime attributes map
      Returns:
    • isProtected

      boolean isProtected()
      Check if the sheet is protected
      Returns:
    • setPassword

      void setPassword(String password)
      Sets password to protect sheet, set null to unprotect it.
      Parameters:
      password -
    • getHashedPassword

      short getHashedPassword()
      Internal Use only.
      Returns:
    • setHashedPassword

      void setHashedPassword(short hashpass)
      Internal User only.
    • getAutoFilter

      SAutoFilter getAutoFilter()
      Gets the auto filter information if there is.
      Returns:
      the auto filter, or null if not found
    • createAutoFilter

      SAutoFilter createAutoFilter(CellRegion region)
      Creates a new auto filter, the old one will be drop directly.
      Parameters:
      region - the auto filter region
      Returns:
      the new auto filter.
    • deleteAutoFilter

      void deleteAutoFilter()
      Delete current autofilter if it has
    • clearAutoFilter

      void clearAutoFilter()
      Clear auto filter if there is.
    • pasteCell

      CellRegion pasteCell(SheetRegion src, CellRegion dest, PasteOption option)
      paste cell from src sheet to this sheet, the sheets must in same book
      Parameters:
      src - src sheet and it's region to paste
      dest - destination region in this sheet
      option - the copy option
      Returns:
      the final effected region
    • getSheetProtection

      SSheetProtection getSheetProtection()
      Gets enhanced protection.
    • getSheetVisible

      SSheet.SheetVisible getSheetVisible()
      Get the sheet current visible state.
      Since:
      3.7.0
    • setSheetVisible

      void setSheetVisible(SSheet.SheetVisible state)
      Set the sheet current visible state.
      Since:
      3.7.0
    • addTable

      void addTable(STable table)
      Add a new table
      Parameters:
      table -
      Since:
      3.8.0
    • getTables

      List<STable> getTables()
      Get tables in this sheet
      Returns:
      Since:
      3.8.0
    • removeTable

      void removeTable(String tableName)
      Remove the table of the specified table name.
      Parameters:
      tableName -
      Since:
      3.8.0
    • setHashValue

      void setHashValue(String hashValue)
      New way of hashing sheet protection password.
      Parameters:
      hashValue -
      Since:
      3.8.1
    • setSpinCount

      void setSpinCount(String spinCount)
      New way of hashing sheet protection password.
      Parameters:
      spinCount -
      Since:
      3.8.1
    • setSaltValue

      void setSaltValue(String saltValue)
      New way of hashing sheet protection password.
      Parameters:
      saltValue -
      Since:
      3.8.1
    • setAlgName

      void setAlgName(String algName)
      New way of hashing sheet protection password.
      Parameters:
      algName -
      Since:
      3.8.1
    • getConditionalFormattings

      List<SConditionalFormatting> getConditionalFormattings()
      Returns the conditional formatting applied to this sheet.
      Returns:
      Since:
      3.8.2
    • getDataRegion

      CellRegion getDataRegion()
      Returns the region which contains data(including chart, picture, and fills) in this sheet; return null if empty sheet.
      Returns:
      the region which contains data(including chart, picture, and fills) in this sheet; return null if empty sheet.
      Since:
      3.8.3
    • setTabColor

      void setTabColor(String tabColor)
      Set sheet tab color
      Since:
      5.2.0
    • getTabColor

      String getTabColor()
      Returns:
      sheet tab color
      Since:
      5.2.0
    • setArrayFormula

      CellRegion setArrayFormula(String formula, CellRegion region)
      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
      region - Region of array formula for result.
      Returns:
      the CellRegion of cells affected by this change
      Since:
      6.0.0
    • removeArrayFormula

      CellRegion removeArrayFormula(SCell cell)
      Remove an 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 CellRegion of cells affected by this change
      Since:
      6.0.0
    • getCellRegionInArrayFormula

      CellRegion getCellRegionInArrayFormula(SCell cell)
      Returns the cell regin if the given cell is in an array formula.
      Parameters:
      cell -
      Since:
      6.0.0
    • getAllArrayFormulas

      List<CellRegion> getAllArrayFormulas()
      Returns all cell regions of array formula in the given sheet
      Since:
      6.0.0
    • setOutlineLevelRow

      void setOutlineLevelRow(int outlineLevelRow)
      Sets the maximum outline level for row represent of this sheet.
      Parameters:
      outlineLevelRow -
      Since:
      6.0.0
    • getOutlineLevelRow

      int getOutlineLevelRow()
      Returns the maximum outline level for row represent.
      Since:
      6.0.0
    • setOutlineLevelCol

      void setOutlineLevelCol(int outlineLevelCol)
      Sets the maximum outline level for column represent of this sheet.
      Parameters:
      outlineLevelCol -
      Since:
      6.0.0
    • getOutlineLevelCol

      int getOutlineLevelCol()
      Returns the maximum outline level for column represent.
      Since:
      6.0.0
    • isApplyStyles

      boolean isApplyStyles()
      Returns whether to apply the styles in outline.

      Default: false

      Since:
      6.0.0
    • setApplyStyles

      void setApplyStyles(boolean applyStyles)
      Sets to apply with the styles in outline.

      Note: Only used for maintaining model state. (not implemented for UI parts)

      Parameters:
      applyStyles - false not to apply
      Since:
      6.0.0
    • isSummaryBelow

      boolean isSummaryBelow()
      Returns whether to display summary below in outline for rows.

      Default: true

      Since:
      6.0.0
    • setSummaryBelow

      void setSummaryBelow(boolean summaryBelow)
      Sets to display summary below in outline for rows.

      Default: true

      Parameters:
      summaryBelow - false to display on top.
      Since:
      6.0.0
    • isSummaryRight

      boolean isSummaryRight()
      Returns whether to display summary right in outline for columns.

      Default: true

      Since:
      6.0.0
    • setSummaryRight

      void setSummaryRight(boolean summaryRight)
      Sets whether to display summary right in outline for columns.

      Default: true

      Parameters:
      summaryRight - false to display on left.
      Since:
      6.0.0
    • isShowOutlineSymbols

      boolean isShowOutlineSymbols()
      Returns whether to display outline symbols.

      Default: true

      Since:
      6.0.0
    • setShowOutlineSymbols

      void setShowOutlineSymbols(boolean showOutlineSymbols)
      Sets whether to display outline symbols.

      Default: true

      Parameters:
      showOutlineSymbols - false not to show.
      Since:
      6.0.0
    • addCellRegionValueChangeListener

      void addCellRegionValueChangeListener(CellRegion cellRegion, SerializableConsumer<CellRegion> listener)
      Adds the listener when specific cell region value change.
      Parameters:
      cellRegion -
      listener -
      Since:
      6.2.0
    • removeCellRegionValueChangeListener

      boolean removeCellRegionValueChangeListener(CellRegion cellRegion)
      Remove all cell region value change listeners of specific cell region.
      Parameters:
      cellRegion -
      Returns:
      whether the listeners are removed successfully.
      Since:
      6.2.0
    • removeCellRegionValueChangeListener

      boolean removeCellRegionValueChangeListener(SerializableConsumer<CellRegion> listener)
      Remove the cell region value change listener.
      Parameters:
      listener -
      Returns:
      whether the listener is removed successfully.
      Since:
      6.2.0
    • addChart

      SChart addChart(String name, SChart.ChartType type, ViewAnchor anchor)
      Add a chart with name, type and anchor
      Parameters:
      name -
      type -
      anchor -
      Returns:
      the created chart
      Since:
      6.2.0
    • getChartByName

      SChart getChartByName(String name)
      Returns the first chart with specific name
      Parameters:
      name -
      Returns:
      the chart with specific name
      Since:
      6.2.0
    • getChartsByName

      List<SChart> getChartsByName(String name)
      Returns the charts with specific name
      Parameters:
      name -
      Returns:
      the charts with specific name
      Since:
      6.2.0