public class XlsCommentAreaBuilder extends Object implements AreaBuilder
XlsArea
from Excel comments in the Excel template
A command is specified in a cell comment like the following
jx:COMMAND_NAME(attr1="value1" attr2="value2" ... attrN="valueN" lastCell="LAST_CELL" areas=["AREA_REF1", "AREA_REF2", ... , "AREA_REFN"])where
Multiple commands can be specified in a single cell comment separated by new lines. In this case the area of the first command will contain the second command and so on.
This class defines the following pre-defined mappings between the command names and Command classes:
"jx:each" -EachCommand
"jx:if" -IfCommand
"jx:area" -AreaCommand
- for defining the top areas "jx:image" -ImageCommand
"jx:grid" -GridCommand
"jx:updateCell" -UpdateCellCommand
"jx:mergeCells" -MergeCellsCommand
Custom command classes mapping can be added using addCommandMapping(String commandName, Class clazz) method
jx:if(condition="employee.payment <= 2000", lastCell="F9", areas=["A9:F9","A30:F30"])
Here we define IfCommand
with a condition expression 'employee.payment <= 2000' and first area (if-area) "A9:F9"
and second area (else-area) "A30:F30". The command is added to the parent area covering a range from the cell where
the comment is placed and to the cell defined in lastCell attribute "F9".
jx:each(items="department.staff", var="employee", lastCell="F9")
Here we define EachCommand
with items attribute set to 'department.staff' and var attribute set to 'employee'.
The command area is defined from the cell where the comment is defined and till the lastCell "F9"
jx:area(lastCell="G26")
Specifies the top area range with AreaCommand
starting from the cell where the comment is defined and in
the cell defined in lastCell("G26").
Note: Clearing comments from the cells appears to have some issues in POI so should be used with caution. The easiest approach will be just removing the template sheet.
Modifier and Type | Field and Description |
---|---|
static String |
COMMAND_PREFIX |
static String |
LINE_SEPARATOR |
static boolean |
MULTI_LINE_SQL_FEATURE
Feature toggle for the multi-line SQL feature (#79).
|
Constructor and Description |
---|
XlsCommentAreaBuilder() |
XlsCommentAreaBuilder(Transformer transformer) |
XlsCommentAreaBuilder(Transformer transformer,
boolean clearTemplateCells) |
Modifier and Type | Method and Description |
---|---|
static void |
addCommandMapping(String commandName,
Class<? extends Command> clazz) |
List<Area> |
build()
Builds a list of
XlsArea objects defined by top level AreaCommand markup ("jx:area")
containing a tree of all nested commands |
Transformer |
getTransformer() |
static boolean |
isCommandString(String str) |
void |
setTransformer(Transformer transformer) |
public static final String COMMAND_PREFIX
public static final String LINE_SEPARATOR
public static boolean MULTI_LINE_SQL_FEATURE
public XlsCommentAreaBuilder()
public XlsCommentAreaBuilder(Transformer transformer)
public XlsCommentAreaBuilder(Transformer transformer, boolean clearTemplateCells)
public Transformer getTransformer()
getTransformer
in interface AreaBuilder
public void setTransformer(Transformer transformer)
setTransformer
in interface AreaBuilder
public static void addCommandMapping(String commandName, Class<? extends Command> clazz)
public List<Area> build()
XlsArea
objects defined by top level AreaCommand markup ("jx:area")
containing a tree of all nested commandsbuild
in interface AreaBuilder
public static boolean isCommandString(String str)
Copyright © 2023. All rights reserved.