Class ExcelSheet
java.lang.Object
io.github.mbenincasa.javaexcelutils.model.excel.ExcelSheet
ExcelSheet is the Sheet wrapper class of the Apache POI library- Since:
- 0.3.0
- Author:
- Mirko Benincasa
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidappendCells(String startingCell, java.util.stream.Stream<Object[]> data) Method that allows you to append a data matrix starting from a source cellcountAllRows(Boolean alsoEmpty) Counts how many Rows are compiledCreate a new Row in the SheetgetIndex()The Sheet index in the WorkbookRetrieves the index of the last RowgetOrCreateRow(Integer index) Retrieve or create a row by indexRetrieve a row by indexgetRows()The list of Rows related to the SheetReturns the Workbook to which it belongsstatic ExcelSheetof(org.apache.poi.ss.usermodel.Sheet sheet) Get to an ExcelSheet instance from Apache POI Sheet<T> List<T>parseToList(Class<T> clazz, ExcelListParserMapping mapping) <T> TparseToObject(Class<T> clazz, String startingCell) voidremove()Remove the selected SheetvoidremoveCells(String cellRange) Method used to delete cells based on the selected range, for example: 'A1:B2'voidRemoves a row by indexvoidwriteCells(String startingCell, java.util.stream.Stream<Object[]> data) Method that allows you to write a data matrix starting from a source cell
-
Constructor Details
-
ExcelSheet
public ExcelSheet()
-
-
Method Details
-
of
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
The Sheet index in the Workbook- Returns:
- The Sheet index
-
getWorkbook
Returns the Workbook to which it belongs- Returns:
- A ExcelWorkbook
-
remove
public void remove()Remove the selected Sheet- Since:
- 0.4.1
-
getRows
The list of Rows related to the Sheet- Returns:
- A list of Rows
-
getRow
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
Retrieve or create a row by index- Parameters:
index- The index of the row requested- Returns:
- A ExcelRow
- Since:
- 0.4.1
-
removeRow
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
Method that allows you to write a data matrix starting from a source cell- Parameters:
startingCell- Source celldata- A matrix data- Since:
- 0.5.0
-
appendCells
Method that allows you to append a data matrix starting from a source cell- Parameters:
startingCell- Source celldata- A matrix data- Since:
- 0.5.0
-
removeCells
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
Create a new Row in the Sheet- Parameters:
index- The index in the Sheet- Returns:
- A Row
-
getLastRowIndex
Retrieves the index of the last Row- Returns:
- The index of the last Row
-
countAllRows
Counts how many Rows are compiled- Parameters:
alsoEmpty-trueif you want to count Rows that have all empty Cells- Returns:
- The number of Rows compiled
-
parseToObject
public <T> T parseToObject(Class<T> clazz, String startingCell) throws NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException, ReadValueException - Type Parameters:
T- The class parameter of the object- Parameters:
clazz- The class of the object to returnstartingCell- The name of the source cell- Returns:
- The object parsed
- Throws:
NoSuchMethodException- If the setting method or empty constructor of the object is not foundInvocationTargetException- If an error occurs while instantiating a new object or setting a fieldInstantiationException- If an error occurs while instantiating a new objectIllegalAccessException- If a field or fields of theclazzcould not be accessedReadValueException- If an error occurs while reading a cell- Since:
- 0.5.0
-
parseToList
public <T> List<T> parseToList(Class<T> clazz, ExcelListParserMapping mapping) throws ReadValueException, InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException - Type Parameters:
T- The class parameter of the object- Parameters:
clazz- The class of the object to returnmapping- The rules to retrieve the list of objects- Returns:
- The object list parsed
- Throws:
ReadValueException- If an error occurs while reading a cellInvocationTargetException- If an error occurs while instantiating a new object or setting a fieldNoSuchMethodException- If the setting method or empty constructor of the object is not foundInstantiationException- If an error occurs while instantiating a new objectIllegalAccessException- If a field or fields of theclazzcould not be accessed- Since:
- 0.5.0
-