|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.gageot.excel.core.ExcelTemplate
public class ExcelTemplate
This is the central class in the Excel core package. It simplifies the use of Excel and helps to avoid common errors. It executes core Excel parsing workflow, leaving application code extract results.
Code using this class need only implement callback interfaces, giving them a clearly defined contract. The RowCallbackHandler interface extracts values from each row of a HSSFSheet.
Can be used within a service implementation via direct instantiation with a Resource reference, or get prepared in an application context and given to services as bean reference.
The motivation and design of this class is inspired from JdbcTemplate.
Because this class is parameterizable by the callback interfaces, it isn't necessary to subclass it.
SheetExtractor
,
RowCallbackHandler
,
RowMapper
Constructor Summary | |
---|---|
ExcelTemplate()
Construct a new ExcelTemplate for bean usage. |
|
ExcelTemplate(java.io.File aFile)
Construct a new ExcelTemplate, given an Excel File. |
|
ExcelTemplate(org.springframework.core.io.Resource aResource)
Construct a new ExcelTemplate, given a Resource to obtain the Excel stream from. |
|
ExcelTemplate(java.lang.String aPath,
java.lang.Class aClass)
Construct a new ExcelTemplate, given a path to an Excel file. |
Method Summary | |
---|---|
void |
afterPropertiesSet()
|
org.springframework.core.io.Resource |
getResource()
Set the Resource to obtain the Excel stream from. |
java.lang.String[][] |
read(java.lang.String sheetName)
|
void |
read(java.lang.String sheetName,
CellCallbackHandler cellCallbackHandler)
|
java.lang.Object[][] |
read(java.lang.String sheetName,
CellMapper cellMapper)
|
java.lang.Object[][] |
read(java.lang.String sheetName,
CellMapper cellMapper,
java.lang.Class clazz)
|
void |
read(java.lang.String sheetName,
RowCallbackHandler rowCallbackHandler)
|
java.lang.Object |
read(java.lang.String sheetName,
SheetExtractor sheetExtractor)
Read the content of an Excel file for a given sheet name. |
java.util.List |
readBeans(java.lang.String sheetName,
java.lang.Class clazz)
|
java.util.List |
readList(java.lang.String sheetName)
|
java.util.List |
readList(java.lang.String sheetName,
CellMapper cellMapper)
|
java.util.List |
readList(java.lang.String sheetName,
RowMapper rowMapper)
|
void |
setResource(org.springframework.core.io.Resource aResource)
Return the Resource used by this template. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ExcelTemplate()
setResource(org.springframework.core.io.Resource)
public ExcelTemplate(org.springframework.core.io.Resource aResource)
aResource
- Resource to obtain the Excel stream frompublic ExcelTemplate(java.io.File aFile)
aFile
- Excel filepublic ExcelTemplate(java.lang.String aPath, java.lang.Class aClass)
aPath
- relative or absolute path within the class pathaClass
- the class to load resources withClass.getResourceAsStream(java.lang.String)
Method Detail |
---|
public java.lang.Object read(java.lang.String sheetName, SheetExtractor sheetExtractor) throws org.springframework.dao.DataAccessException
sheetName
- name of the excel sheetsheetExtractor
- object that will extract results
org.springframework.dao.DataAccessException
- if there is any problempublic java.lang.String[][] read(java.lang.String sheetName) throws org.springframework.dao.DataAccessException
org.springframework.dao.DataAccessException
public java.lang.Object[][] read(java.lang.String sheetName, CellMapper cellMapper) throws org.springframework.dao.DataAccessException
org.springframework.dao.DataAccessException
public java.lang.Object[][] read(java.lang.String sheetName, CellMapper cellMapper, java.lang.Class clazz) throws org.springframework.dao.DataAccessException
org.springframework.dao.DataAccessException
public java.util.List readList(java.lang.String sheetName, RowMapper rowMapper) throws org.springframework.dao.DataAccessException
org.springframework.dao.DataAccessException
public java.util.List readList(java.lang.String sheetName) throws org.springframework.dao.DataAccessException
org.springframework.dao.DataAccessException
public java.util.List readList(java.lang.String sheetName, CellMapper cellMapper) throws org.springframework.dao.DataAccessException
org.springframework.dao.DataAccessException
public void read(java.lang.String sheetName, RowCallbackHandler rowCallbackHandler) throws org.springframework.dao.DataAccessException
org.springframework.dao.DataAccessException
public void read(java.lang.String sheetName, CellCallbackHandler cellCallbackHandler) throws org.springframework.dao.DataAccessException
org.springframework.dao.DataAccessException
public java.util.List readBeans(java.lang.String sheetName, java.lang.Class clazz) throws org.springframework.dao.DataAccessException
org.springframework.dao.DataAccessException
public org.springframework.core.io.Resource getResource()
public void setResource(org.springframework.core.io.Resource aResource)
public void afterPropertiesSet()
afterPropertiesSet
in interface org.springframework.beans.factory.InitializingBean
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |