public class Util extends Object
Modifier and Type | Field and Description |
---|---|
static String |
regexAreaRef |
static Pattern |
regexAreaRefPattern |
static String |
regexCellRef |
static String |
regexCellRefExcludingJointed |
static String |
regexExcludePrefixSymbols |
static String |
regexJointedCellRef |
static String |
regexJointedLookBehind |
static String |
regexSimpleCellRef |
Constructor and Description |
---|
Util() |
Modifier and Type | Method and Description |
---|---|
static int |
countOccurences(String str,
char ch)
Calculates a number of occurences of a symbol in the string
|
static String |
createTargetCellRef(List<CellRef> targetCellDataList)
Combines a list of cell references into a range
E.g.
|
static List<CellRef> |
createTargetCellRefListByColumn(CellRef targetFormulaCellRef,
List<CellRef> targetCells,
List<CellRef> cellRefsToExclude)
Creates a list of target formula cell references
|
static boolean |
formulaContainsJointedCellRef(String formula)
Checks if the formula contains jointed cell references
Jointed references have format U_(cell1, cell2) e.g.
|
static List<String> |
getCellRefsFromJointedCellRef(String jointedCellRef)
Parses a "jointed cell" reference and extracts individual cell references
|
static List<String> |
getFormulaCellRefs(String formula)
Parses a formula and returns a list of cell names used in it
E.g.
|
static List<String> |
getJointedCellRefs(String formula)
Parses a formula to extract a list of so called "jointed cells"
The jointed cells are cells combined with a special notation "U_(cell1, cell2)" into a single cell
They are used in formulas like this "$[SUM(U_(F8,F13))]".
|
static Object |
getObjectProperty(Object obj,
String propertyName)
Gets value of the passed object by the given property name.
|
static Object |
getObjectProperty(Object obj,
String propertyName,
boolean failSilently)
Gets value of the passed object by the given property name.
|
static List<String> |
getSheetsNameOfMultiSheetTemplate(List<Area> areaList)
Return names of all multi sheet template
|
static String |
getStrictCellNameRegex(String name) |
static List<List<CellRef>> |
groupByColRange(List<CellRef> cellRefList)
Groups a list of cell references in a column into a list of ranges
|
static List<List<CellRef>> |
groupByRanges(List<CellRef> cellRefList,
int targetRangeCount)
Groups a list of cell references into a list ranges which can be used in a formula substitution
|
static List<List<CellRef>> |
groupByRowRange(List<CellRef> cellRefList)
Groups a list of cell references in a row into a list of ranges
|
static Collection<GroupData> |
groupCollection(Collection<?> collection,
String groupProperty,
String groupOrder)
Similar to
groupIterable(Iterable, String, String) method but works for collections |
static Collection<GroupData> |
groupIterable(Iterable<?> iterable,
String groupProperty,
String groupOrder)
Groups items from an iterable collection using passed group property and group order
|
static Boolean |
isConditionTrue(ExpressionEvaluator evaluator,
Context context)
Evaluates if the passed condition is true
|
static Boolean |
isConditionTrue(ExpressionEvaluator evaluator,
String condition,
Context context)
Evaluates if the passed condition is true
|
static String |
joinStrings(List<String> strings,
String separator)
Joins strings with a separator
|
static void |
setObjectProperty(Object obj,
String propertyName,
String propertyValue)
Dynamically sets an object property via reflection
|
static void |
setObjectProperty(Object obj,
String propertyName,
String propertyValue,
boolean ignoreNonExisting)
Dynamically sets an object property via reflection
|
static String |
sheetNameRegex(Map.Entry<CellRef,List<CellRef>> cellRefEntry) |
static byte[] |
toByteArray(InputStream stream)
Reads all the data from the input stream, and returns the bytes read.
|
static Collection<?> |
transformToCollectionObject(ExpressionEvaluator expressionEvaluator,
String collectionName,
Context context)
Evaluates passed collection name into a
Collection object |
static Iterable<Object> |
transformToIterableObject(ExpressionEvaluator expressionEvaluator,
String collectionName,
Context context)
Evaluates the passed collection name into an
Iterable object |
public static final String regexJointedLookBehind
public static final String regexSimpleCellRef
public static final String regexCellRef
public static final String regexAreaRef
public static final Pattern regexAreaRefPattern
public static final String regexCellRefExcludingJointed
public static final String regexJointedCellRef
public static final String regexExcludePrefixSymbols
public static List<String> getFormulaCellRefs(String formula)
formula
- stringpublic static List<String> getJointedCellRefs(String formula)
formula
- a formula string to parsepublic static List<String> getCellRefsFromJointedCellRef(String jointedCellRef)
jointedCellRef
- a jointed cell reference to parsepublic static boolean formulaContainsJointedCellRef(String formula)
formula
- stringpublic static String createTargetCellRef(List<CellRef> targetCellDataList)
targetCellDataList
- -public static String joinStrings(List<String> strings, String separator)
strings
- -separator
- -public static List<List<CellRef>> groupByRanges(List<CellRef> cellRefList, int targetRangeCount)
cellRefList
- a list of cell referencestargetRangeCount
- a number of ranges to use when groupingpublic static List<List<CellRef>> groupByColRange(List<CellRef> cellRefList)
cellRefList
- -public static List<List<CellRef>> groupByRowRange(List<CellRef> cellRefList)
cellRefList
- -public static Boolean isConditionTrue(ExpressionEvaluator evaluator, String condition, Context context)
evaluator
- expression evaluator instancecondition
- condition stringcontext
- Jxls context to use for evaluationpublic static Boolean isConditionTrue(ExpressionEvaluator evaluator, Context context)
evaluator
- -context
- Jxls context to use for evaluationpublic static void setObjectProperty(Object obj, String propertyName, String propertyValue, boolean ignoreNonExisting)
obj
- -propertyName
- -propertyValue
- -ignoreNonExisting
- -public static void setObjectProperty(Object obj, String propertyName, String propertyValue) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException
obj
- -propertyName
- -propertyValue
- -NoSuchMethodException
- -InvocationTargetException
- -IllegalAccessException
- -public static Object getObjectProperty(Object obj, String propertyName, boolean failSilently)
obj
- Map, DynaBean or Java beanpropertyName
- -failSilently
- -public static Object getObjectProperty(Object obj, String propertyName) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException
obj
- Map, DynaBean or Java beanpropertyName
- -NoSuchMethodException
- -InvocationTargetException
- -IllegalAccessException
- -public static Collection<GroupData> groupCollection(Collection<?> collection, String groupProperty, String groupOrder)
groupIterable(Iterable, String, String)
method but works for collectionscollection
- -groupProperty
- -groupOrder
- -public static Collection<GroupData> groupIterable(Iterable<?> iterable, String groupProperty, String groupOrder)
iterable
- iterable objectgroupProperty
- property to use to group the itemsgroupOrder
- an order to sort the groupspublic static byte[] toByteArray(InputStream stream) throws IOException
stream
- -IOException
- -public static Collection<?> transformToCollectionObject(ExpressionEvaluator expressionEvaluator, String collectionName, Context context)
Collection
objectexpressionEvaluator
- -collectionName
- -context
- -Collection
instancepublic static String sheetNameRegex(Map.Entry<CellRef,List<CellRef>> cellRefEntry)
cellRefEntry
- -public static List<CellRef> createTargetCellRefListByColumn(CellRef targetFormulaCellRef, List<CellRef> targetCells, List<CellRef> cellRefsToExclude)
targetFormulaCellRef
- -targetCells
- -cellRefsToExclude
- -public static int countOccurences(String str, char ch)
str
- -ch
- -public static Iterable<Object> transformToIterableObject(ExpressionEvaluator expressionEvaluator, String collectionName, Context context)
Iterable
objectexpressionEvaluator
- -collectionName
- -context
- -Context
under given namepublic static String getStrictCellNameRegex(String name)
name
- -Copyright © 2023. All rights reserved.