java.lang.Object
io.github.mbenincasa.javaexcelutils.model.excel.ExcelSheet

public class ExcelSheet extends Object
ExcelSheet is the Sheet wrapper class of the Apache POI library
Since:
0.3.0
Author:
Mirko Benincasa
  • Constructor Details

    • ExcelSheet

      public ExcelSheet()
  • Method Details

    • of

      public static ExcelSheet of(org.apache.poi.ss.usermodel.Sheet sheet)
      Get to an ExcelSheet instance from Apache POI Sheet
      Parameters:
      sheet - The Sheet instance to wrap
      Returns:
      The ExcelSheet instance
      Since:
      0.5.0
    • getIndex

      public Integer getIndex()
      The Sheet index in the Workbook
      Returns:
      The Sheet index
    • getWorkbook

      public ExcelWorkbook getWorkbook()
      Returns the Workbook to which it belongs
      Returns:
      A ExcelWorkbook
    • remove

      public void remove()
      Remove the selected Sheet
      Since:
      0.4.1
    • getRows

      public List<ExcelRow> getRows()
      The list of Rows related to the Sheet
      Returns:
      A list of Rows
    • getRow

      public ExcelRow getRow(Integer index) throws RowNotFoundException
      Retrieve a row by index
      Parameters:
      index - The index of the row requested
      Returns:
      A ExcelRow
      Throws:
      RowNotFoundException - If the row is not present or has not been created
      Since:
      0.4.1
    • getOrCreateRow

      public ExcelRow getOrCreateRow(Integer index)
      Retrieve or create a row by index
      Parameters:
      index - The index of the row requested
      Returns:
      A ExcelRow
      Since:
      0.4.1
    • removeRow

      public void removeRow(Integer index) throws RowNotFoundException
      Removes a row by index
      Parameters:
      index - The index of the row to remove
      Throws:
      RowNotFoundException - If the row is not present or has not been created
      Since:
      0.4.1
    • writeCells

      public void writeCells(String startingCell, java.util.stream.Stream<Object[]> data)
      Method that allows you to write a data matrix starting from a source cell
      Parameters:
      startingCell - Source cell
      data - A matrix data
      Since:
      0.5.0
    • appendCells

      public void appendCells(String startingCell, java.util.stream.Stream<Object[]> data)
      Method that allows you to append a data matrix starting from a source cell
      Parameters:
      startingCell - Source cell
      data - A matrix data
      Since:
      0.5.0
    • removeCells

      public void removeCells(String cellRange)
      Method used to delete cells based on the selected range, for example: 'A1:B2'
      Parameters:
      cellRange - The range of cells to be deleted
      Since:
      0.5.0
    • createRow

      public ExcelRow createRow(Integer index)
      Create a new Row in the Sheet
      Parameters:
      index - The index in the Sheet
      Returns:
      A Row
    • getLastRowIndex

      public Integer getLastRowIndex()
      Retrieves the index of the last Row
      Returns:
      The index of the last Row
    • countAllRows

      public Integer countAllRows(Boolean alsoEmpty)
      Counts how many Rows are compiled
      Parameters:
      alsoEmpty - true if you want to count Rows that have all empty Cells
      Returns:
      The number of Rows compiled
    • parseToObject

      Type Parameters:
      T - The class parameter of the object
      Parameters:
      clazz - The class of the object to return
      startingCell - The name of the source cell
      Returns:
      The object parsed
      Throws:
      NoSuchMethodException - If the setting method or empty constructor of the object is not found
      InvocationTargetException - If an error occurs while instantiating a new object or setting a field
      InstantiationException - If an error occurs while instantiating a new object
      IllegalAccessException - If a field or fields of the clazz could not be accessed
      ReadValueException - If an error occurs while reading a cell
      Since:
      0.5.0
    • parseToList

      Type Parameters:
      T - The class parameter of the object
      Parameters:
      clazz - The class of the object to return
      mapping - The rules to retrieve the list of objects
      Returns:
      The object list parsed
      Throws:
      ReadValueException - If an error occurs while reading a cell
      InvocationTargetException - If an error occurs while instantiating a new object or setting a field
      NoSuchMethodException - If the setting method or empty constructor of the object is not found
      InstantiationException - If an error occurs while instantiating a new object
      IllegalAccessException - If a field or fields of the clazz could not be accessed
      Since:
      0.5.0