Package org.jxls.command
Class EachCommand
java.lang.Object
org.jxls.command.AbstractCommand
org.jxls.command.EachCommand
- All Implemented Interfaces:
Command
Implements iteration over collection or array of items
- 'items' is a bean name of the collection or array in context
- 'var' is a name of a collection item to put into the context during the iteration
- 'varIndex' is name of variable in context that holds current iteration index, 0 based. Use ${varIndex+1} for 1 based.
- 'direction' defines expansion by rows (DOWN) or by columns (RIGHT). Default is DOWN.
- 'select' holds an expression for filtering collection.
- 'groupBy' is the name for grouping (prepend var+".").
- 'groupOrder' defines the grouping order. Case does not matter. "ASC" for ascending, "DESC" for descending sort order. Other values or null: no sorting.
- 'orderBy' contains the names separated with comma and each with an optional postfix " ASC" (default) or " DESC" for the sort order. Prepend var+'.' before each name.
- 'multisheet' is the name of the sheet names container.
- 'cellRefGenerator' defines custom strategy for target cell references.
The variables defined in 'var' and 'varIndex' will be saved using the special method Context.getRunVar()
- Author:
- Leonid Vysochyn
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsFields inherited from class org.jxls.command.AbstractCommand
areaListFields inherited from interface org.jxls.command.Command
ADJACENT_SHIFT_MODE, INNER_SHIFT_MODE -
Constructor Summary
ConstructorsConstructorDescriptionEachCommand(String var, String items, Area area) EachCommand(String var, String items, Area area, CellRefGenerator cellRefGenerator) EachCommand(String var, String items, Area area, EachCommand.Direction direction) EachCommand(String var, String items, EachCommand.Direction direction) EachCommand(String items, Area area) -
Method Summary
Modifier and TypeMethodDescriptionAdds an area to this commandApplies a command at the given cell referenceGets defined cell ref generatorGets iteration directiongetItems()Gets collection bean namegetName()Gets current 'select' expression for filtering out collection itemsgetVar()Gets current variable name for collection item in the context during iterationbooleanvoidsetCellRefGenerator(CellRefGenerator cellRefGenerator) voidsetDirection(String direction) voidsetDirection(EachCommand.Direction direction) Sets iteration directionvoidsetGroupBy(String groupBy) voidsetGroupOrder(String groupOrder) voidSets collection bean namevoidsetMultisheet(String multisheet) Sets name of context variable holding a list of Excel sheet names to output the collection tovoidsetOldSelectBehavior(boolean oldSelectBehavior) voidsetOldSelectBehavior(String oldSelectBehavior) voidsetOrderBy(String orderBy) voidSets current 'select' expression for filtering collectionvoidSets current variable name for collection item in the context during iterationvoidsetVarIndex(String varIndex) Methods inherited from class org.jxls.command.AbstractCommand
getAreaList, getLockRange, getLogger, getShiftMode, getTransformer, reset, setLockRange, setLockRange, setShiftMode, transformToIterableObject
-
Field Details
-
COMMAND_NAME
- See Also:
-
-
Constructor Details
-
EachCommand
public EachCommand() -
EachCommand
- Parameters:
var- name of the key in the context to contain each collection items during iterationitems- name of collection or array in the contextdirection- defines processing by rows (DOWN - default) or columns (RIGHT)
-
EachCommand
-
EachCommand
-
EachCommand
-
EachCommand
- Parameters:
var- name of the key in the context to contain each collection items during iterationitems- name of collection or array in the contextarea- body area for this commandcellRefGenerator- generates target cell ref for each collection item during iteration
-
-
Method Details
-
getName
- Returns:
- command name
-
getItems
Gets collection bean name- Returns:
- collection name of collection or array in the context
-
setItems
Sets collection bean name- Parameters:
items- name of collection or array in the context
-
getVar
Gets current variable name for collection item in the context during iteration- Returns:
- collection item key name in the context
-
setVar
Sets current variable name for collection item in the context during iteration- Parameters:
var- name of the loop var
-
getVarIndex
- Returns:
- variable name to put the current iteration index, 0 based
-
setVarIndex
-
getDirection
Gets iteration direction- Returns:
- current direction for iteration
-
setDirection
Sets iteration direction- Parameters:
direction- iteration direction
-
setDirection
- Parameters:
direction- "DOWN" or "RIGHT"
-
getSelect
Gets current 'select' expression for filtering out collection items- Returns:
- current 'select' expression or null if undefined
-
setSelect
Sets current 'select' expression for filtering collection- Parameters:
select- filtering expression
-
getGroupBy
- Returns:
- property name for grouping the collection
-
setGroupBy
- Parameters:
groupBy- property name for grouping the collection. You should write the run var name + "." before the property name.
-
getGroupOrder
- Returns:
- group order
-
setGroupOrder
- Parameters:
groupOrder- group ordering: "ASC" for ascending, "DESC" for descending, other value or null: no sorting. Case does not matter.
-
setOrderBy
- Parameters:
orderBy- property names for ordering the list. You should write the run var name + "." before each property name. You can write " ASC" or " DESC" after each property name for ascending/descending sorting order. ASC is the default.
-
getOrderBy
- Returns:
- property names for ordering the list
-
getMultisheet
- Returns:
- Context variable name holding a list of Excel sheet names to output the collection to
-
setMultisheet
Sets name of context variable holding a list of Excel sheet names to output the collection to- Parameters:
multisheet- var name
-
getCellRefGenerator
Gets defined cell ref generator- Returns:
- current
CellRefGeneratorinstance or null
-
setCellRefGenerator
-
isOldSelectBehavior
public boolean isOldSelectBehavior() -
setOldSelectBehavior
public void setOldSelectBehavior(boolean oldSelectBehavior) -
setOldSelectBehavior
-
addArea
Description copied from interface:CommandAdds an area to this command- Specified by:
addAreain interfaceCommand- Overrides:
addAreain classAbstractCommand- Parameters:
area- to be added area- Returns:
- this command instance
-
applyAt
Description copied from interface:CommandApplies a command at the given cell reference- Parameters:
cellRef- cell reference where the command must be appliedcontext- bean context to use- Returns:
- size of enclosing command area after transformation
-