Class XLSXEngine
java.lang.Object
java.util.Observable
com.nomagic.magicreport.engine.AbstractTemplateEngine
com.nomagic.magicreport.engine.velocity.DefaultTemplateEngine
com.nomagic.magicreport.engine.velocity.XLSXEngine
- All Implemented Interfaces:
IExtensionTemplateEngine,com.nomagic.magicreport.engine.IRuntimeInstanceVelocityEngine,ITemplateEngine,StyledDocument
The Velocity engine for OpenXML Excel Workbook (XLSX).
- Since:
- Dec 14, 2009
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classClass for hadler sheet data in XLSX. -
Field Summary
Fields inherited from class com.nomagic.magicreport.engine.velocity.DefaultTemplateEngine
velocityContextFields inherited from class com.nomagic.magicreport.engine.AbstractTemplateEngine
context, isAborted, preProcessFile, processFile, properties -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintAdd color for html to XLSX.intAdd font for html to XLSX.voidAdd image format to list.intAdd list for html to XLSX.intAppends object content into the document.intAdd style for html to XLSX.protected ParseErrorExceptioncreateParseErrorWrapper(ParseErrorException parseError, Reader source) Create a ParseErrorException from the message.Creates a newTemplateobject for generating report by this engine.createTemplate(File input, File output) Creates a newTemplateobject.createTemplate(File input, File output, boolean ignoreLocation) Creates a newTemplateobject.voidMerge a template with current context and rendered stream into the writer.intReturn XLSX entry set.float[]Return page size.Return template.protected voidhandleForColumn(Template template, StringBuilder inProcessBuffer) Handle the #forcol directive.protected voidhandleForPage(Template template, StringBuilder inProcessBuffer) Handle the #forpage directive.protected voidhandleForRow(Template template, StringBuilder inProcessBuffer) Handle the #forrow directive.protected voidhandleMergeColumns(Template template, StringBuilder inProcessBuffer) Handle $tableprop.mergeColumns directiveprotected voidhandleMergeRows(Template template, StringBuilder inProcessBuffer) Handle $tableprop.mergeRows directivevoidprotected intCount number of line from given content string.protected voidpostProcess(Template template) Perform a post-processing after the template has been evaluated.protected TemplateExceptionprocessException(Template template, ParseErrorException e) Call this method to process aParseErrorException.protected TemplateExceptionprocessVelocityException(Template template, org.apache.velocity.exception.ParseErrorException e) Call this method to process an Velocity exception and return in new format.voidsetChartID(int chartID) protected BufferedWritersetWriterForEvaluate(Template template) protected voidtranslate(Template template, StringBuilder inProcessBuffer) Process the template ininProcessBufferinto valid format.Methods inherited from class com.nomagic.magicreport.engine.velocity.DefaultTemplateEngine
abort, checkFileNotFoundException, clearTools, createComment, destroy, getClassLoader, getFormatter, getResolvedSectionName, handleImport, handleIncludeSection, handleSectionBegin, isNoSpaceException, preProcess, process, process, processVelocityException, setClassLoader, setFormatter, setLatestLocation, setLocation, setProperty, trimTrailSpaceMethods inherited from class com.nomagic.magicreport.engine.AbstractTemplateEngine
addContext, addInvalidReferenceHandler, addObserver, addReferenceInsertionHandler, evaluate, getConcurrentToolException, getContext, getCurrentRuntimeInstance, getInvalidReferenceHandler, getProcessSize, getProperties, getProperty, getReferenceInsertionHandler, isMemoryMode, notifyObservers, observers, setConcurrentToolException, setContext, setCurrentRuntimeInstanceMethods inherited from class java.util.Observable
clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, setChanged
-
Constructor Details
-
XLSXEngine
public XLSXEngine()A class constructor.
-
-
Method Details
-
createTemplate
Creates a newTemplateobject for generating report by this engine.- Specified by:
createTemplatein interfaceITemplateEngine- Overrides:
createTemplatein classDefaultTemplateEngine- Returns:
- an instance of
Template - See Also:
-
createTemplate
Creates a newTemplateobject.- Specified by:
createTemplatein interfaceITemplateEngine- Overrides:
createTemplatein classDefaultTemplateEngine- Parameters:
input- template file.output- output file.- Returns:
- an instance of
Template - Throws:
FileNotFoundException- if the file does not exist, is a directory rather than a regular file, or for some other reason cannot be opened.IOException- If an I/O error occurs
-
createTemplate
Creates a newTemplateobject.- Overrides:
createTemplatein classDefaultTemplateEngine- Parameters:
input- template file.output- output file.ignoreLocation- true to ignore location property for child document- Returns:
- an instance of
Template - Throws:
FileNotFoundException- if the file does not exist, is a directory rather than a regular file, or for some other reason cannot be opened.IOException- If an I/O error occurs
-
getTemplate
Return template.- Returns:
- a XLSX template
-
getEntrySet
Return XLSX entry set.- Returns:
- XLSX entry set.
-
addImage
Add image format to list.- Parameters:
format- format of image
-
getPageSize
public float[] getPageSize()Return page size.- Returns:
- float[] pageSize
-
getChartID
public int getChartID() -
setChartID
public void setChartID(int chartID) -
increaseChartID
public void increaseChartID() -
evaluate
Merge a template with current context and rendered stream into the writer.- Specified by:
evaluatein interfaceITemplateEngine- Overrides:
evaluatein classAbstractTemplateEngine- Parameters:
template- Template being evaluated- Throws:
ParseErrorException- if a syntax or other error which prevents it from being parsed.InitializationEngineException- error while initializing engineTemplateException- other error while processing the template- See Also:
-
setWriterForEvaluate
- Overrides:
setWriterForEvaluatein classDefaultTemplateEngine
-
translate
protected void translate(Template template, StringBuilder inProcessBuffer) throws ParseErrorException, IOException Process the template ininProcessBufferinto valid format.- Overrides:
translatein classDefaultTemplateEngine- Parameters:
template- Template source.inProcessBuffer- in process buffer.- Throws:
ParseErrorException- when error while translation, or syntax not recognized.IOException- if IO Error occurs while reading template.
-
createParseErrorWrapper
protected ParseErrorException createParseErrorWrapper(ParseErrorException parseError, Reader source) Create a ParseErrorException from the message.- Parameters:
parseError- root causesource- source template- Returns:
- instance of ParseErrorException
-
processException
Call this method to process aParseErrorException. This method call internally bypostProcess(Template). If code was performed by Velocity (DefaultTemplateEngine.process(Template)), uses methodprocessVelocityException(Template, org.apache.velocity.exception.ParseErrorException). By default this method try to calculate line number fromParseErrorException.getSource().- Overrides:
processExceptionin classDefaultTemplateEngine- Parameters:
template- Templatee- MagicReport parse error exception- Returns:
- TemplateException
-
processVelocityException
protected TemplateException processVelocityException(Template template, org.apache.velocity.exception.ParseErrorException e) Call this method to process an Velocity exception and return in new format. OverrideDefaultTemplateEngine.processVelocityException(Template, org.apache.velocity.exception.ParseErrorException)to return exception with valid ODF line count.- Overrides:
processVelocityExceptionin classDefaultTemplateEngine- Parameters:
template- Templatee- Velocity exception- Returns:
- TemplateException
-
lineCount
Count number of line from given content string.- Overrides:
lineCountin classDefaultTemplateEngine- Parameters:
content- the input string- Returns:
- number of line
-
handleForPage
protected void handleForPage(Template template, StringBuilder inProcessBuffer) throws ParseErrorException Handle the #forpage directive.- Overrides:
handleForPagein classDefaultTemplateEngine- Parameters:
template- Template source.inProcessBuffer- in process buffer.- Throws:
ParseErrorException- when error while translation, or syntax not recognized.
-
handleForColumn
protected void handleForColumn(Template template, StringBuilder inProcessBuffer) throws ParseErrorException Handle the #forcol directive.- Parameters:
template- Template source.inProcessBuffer- in process buffer.- Throws:
ParseErrorException- when error while translation, or syntax not recognized.
-
handleMergeColumns
protected void handleMergeColumns(Template template, StringBuilder inProcessBuffer) throws ParseErrorException Handle $tableprop.mergeColumns directive- Parameters:
template- Template source.inProcessBuffer- in process buffer.- Throws:
ParseErrorException- when error while translation, or syntax not recognized.
-
handleForRow
protected void handleForRow(Template template, StringBuilder inProcessBuffer) throws ParseErrorException Handle the #forrow directive.- Overrides:
handleForRowin classDefaultTemplateEngine- Parameters:
template- Template source.inProcessBuffer- in process buffer.- Throws:
ParseErrorException- when error while translation, or syntax not recognized.
-
handleMergeRows
protected void handleMergeRows(Template template, StringBuilder inProcessBuffer) throws ParseErrorException Handle $tableprop.mergeRows directive- Parameters:
template- Template source.inProcessBuffer- in process buffer.- Throws:
ParseErrorException- when error while translation, or syntax not recognized.
-
postProcess
Perform a post-processing after the template has been evaluated.- Overrides:
postProcessin classDefaultTemplateEngine- Parameters:
template- template after evaluated.- Throws:
ParseErrorException- if a syntax or other error which prevents it from being parsed.InitializationEngineException- error while initializing engineTemplateException- other error while processing the template- See Also:
-
addFont
Add font for html to XLSX.- Specified by:
addFontin interfaceStyledDocument- Parameters:
font- font- Returns:
- font id
-
addList
Add list for html to XLSX.- Specified by:
addListin interfaceStyledDocument- Parameters:
list- list- Returns:
- list id
-
addStyle
Add style for html to XLSX.- Specified by:
addStylein interfaceStyledDocument- Parameters:
style- style- Returns:
- style id
-
addColor
Add color for html to XLSX.- Specified by:
addColorin interfaceStyledDocument- Parameters:
color- color- Returns:
- color id
-
addObject
Appends object content into the document.- Specified by:
addObjectin interfaceStyledDocument- Parameters:
object- adding object- Returns:
- index to object
-