Package org.datanucleus.store.excel
Class ExcelUtils
- java.lang.Object
-
- org.datanucleus.store.excel.ExcelUtils
-
public class ExcelUtils extends Object
Class providing convenience methods for handling Excel datastores. Please refer to Apache POI http://poi.apache.org
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description protected static boolean
cellMatches(org.apache.poi.ss.usermodel.Cell cell, Class fieldType, Object fieldValue)
Convenience method to check if a cell value matches the provided value and type.static int
getNumberOfRowsInSheetOfWorkbook(org.datanucleus.state.ObjectProvider op, org.apache.poi.ss.usermodel.Workbook wb)
Convenience method to find the number of rows in a workbook.static int
getRowNumberForObjectInWorkbook(org.datanucleus.state.ObjectProvider op, org.apache.poi.ss.usermodel.Workbook wb, boolean originalValue, org.datanucleus.store.schema.table.Table table)
Convenience method to find the row number of an object in the provided workbook.static org.apache.poi.ss.usermodel.Sheet
getSheetForClass(org.datanucleus.state.ObjectProvider op, org.apache.poi.ss.usermodel.Workbook wb, org.datanucleus.store.schema.table.Table table)
Convenience method to return the worksheet used for storing the specified object.
-
-
-
Method Detail
-
getSheetForClass
public static org.apache.poi.ss.usermodel.Sheet getSheetForClass(org.datanucleus.state.ObjectProvider op, org.apache.poi.ss.usermodel.Workbook wb, org.datanucleus.store.schema.table.Table table)
Convenience method to return the worksheet used for storing the specified object.- Parameters:
op
- ObjectProvider for the objectwb
- Workbooktable
- The table representing this worksheet- Returns:
- The Work Sheet
- Throws:
org.datanucleus.exceptions.NucleusDataStoreException
- if the work sheet doesn't exist in this workbook
-
getRowNumberForObjectInWorkbook
public static int getRowNumberForObjectInWorkbook(org.datanucleus.state.ObjectProvider op, org.apache.poi.ss.usermodel.Workbook wb, boolean originalValue, org.datanucleus.store.schema.table.Table table)
Convenience method to find the row number of an object in the provided workbook. For application-identity does a search for a row with the specified PK field values. For datastore-identity does a search for the row with the datastore column having the specified value- Parameters:
op
- ObjectProvider for the objectwb
- WorkbookoriginalValue
- Use the original value of the identifiying fields if available (for when we are updating and using nondurable identity).table
- The table representing this worksheet- Returns:
- The row number (or -1 if not found)
-
cellMatches
protected static boolean cellMatches(org.apache.poi.ss.usermodel.Cell cell, Class fieldType, Object fieldValue)
Convenience method to check if a cell value matches the provided value and type.- Parameters:
cell
- The cellfieldType
- The type to compare it withfieldValue
- The value of the type to compare it with (can be null)- Returns:
- Whether the cell matches
-
getNumberOfRowsInSheetOfWorkbook
public static int getNumberOfRowsInSheetOfWorkbook(org.datanucleus.state.ObjectProvider op, org.apache.poi.ss.usermodel.Workbook wb)
Convenience method to find the number of rows in a workbook. This takes into account the fact that it seems to be impossible (with Apache POI 3.0.2) to delete rows from a sheet. Consequently what we do is leave the row but delete all cells. When returning the number of rows this ignores rows that have no cells.- Parameters:
op
- ObjectProvider for the objectwb
- Workbook- Returns:
- Number of (active) rows (or 0 if no active rows)
-
-