T - the typepublic abstract class AbstractExcelItemReader<T>
extends org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader<T>
implements org.springframework.batch.item.file.ResourceAwareItemReaderItemStream<T>, org.springframework.beans.factory.InitializingBean
ItemReader implementation to read an Excel
file. It will read the file sheet for sheet and row for row. It is loosy based on
the FlatFileItemReader| Modifier and Type | Field and Description |
|---|---|
protected org.apache.commons.logging.Log |
logger |
| Constructor and Description |
|---|
AbstractExcelItemReader() |
| Modifier and Type | Method and Description |
|---|---|
void |
afterPropertiesSet() |
protected void |
doClose() |
protected void |
doOpen() |
protected T |
doRead() |
protected abstract int |
getNumberOfSheets()
The number of sheets in the underlying workbook.
|
protected abstract Sheet |
getSheet(int sheet) |
protected void |
jumpToItem(int itemIndex)
On restart this will increment rowSet to where job left off previously
|
protected abstract void |
openExcelFile(java.io.InputStream resource) |
T |
read() |
void |
setEndAfterBlankLines(int endAfterBlankLines) |
void |
setLinesToSkip(int linesToSkip)
Set the number of lines to skip.
|
void |
setResource(org.springframework.core.io.Resource resource)
Public setter for the input resource.
|
void |
setRowMapper(RowMapper<T> rowMapper)
Public setter for the
rowMapper. |
void |
setRowSetFactory(RowSetFactory rowSetFactory)
Public setter for the
rowSetFactory. |
void |
setSkippedRowsCallback(RowCallbackHandler skippedRowsCallback) |
void |
setStrict(boolean strict)
In strict mode the reader will throw an exception on
AbstractItemCountingItemStreamItemReader.open(org.springframework.batch.item.ExecutionContext) if the input resource does not exist. |
close, getCurrentItemCount, isSaveState, open, setCurrentItemCount, setMaxItemCount, setSaveState, updategetExecutionContextKey, setExecutionContextName, setNamepublic T read() throws java.lang.Exception, org.springframework.batch.item.UnexpectedInputException, org.springframework.batch.item.ParseException
read in interface org.springframework.batch.item.ItemReader<T>read in class org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader<T>java.lang.Exceptionorg.springframework.batch.item.UnexpectedInputExceptionorg.springframework.batch.item.ParseExceptionprotected T doRead() throws java.lang.Exception
doRead in class org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader<T>setRowMapper(RowMapper) (might span multiple rows in file).java.lang.Exceptionprotected void jumpToItem(int itemIndex)
throws java.lang.Exception
jumpToItem in class org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader<T>java.lang.Exceptionprotected void doOpen()
throws java.lang.Exception
doOpen in class org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader<T>java.lang.Exceptionprotected void doClose()
throws java.lang.Exception
doClose in class org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader<T>java.lang.Exceptionpublic void setResource(org.springframework.core.io.Resource resource)
setResource in interface org.springframework.batch.item.file.ResourceAwareItemReaderItemStream<T>resource - the Resource pointing to the Excelfilepublic void afterPropertiesSet()
throws java.lang.Exception
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBeanjava.lang.Exceptionpublic void setLinesToSkip(int linesToSkip)
linesToSkip - number of lines to skipprotected abstract Sheet getSheet(int sheet)
sheet - the sheet indexnull when no sheet available.protected abstract int getNumberOfSheets()
protected abstract void openExcelFile(java.io.InputStream resource)
throws java.lang.Exception
resource - Resource pointing to the Excel file to readjava.lang.Exception - when the Excel sheet cannot be accessedpublic void setStrict(boolean strict)
AbstractItemCountingItemStreamItemReader.open(org.springframework.batch.item.ExecutionContext) if the input resource does not exist.strict - true by defaultpublic void setRowMapper(RowMapper<T> rowMapper)
rowMapper. Used to map a row read from the underlying Excel workbook.rowMapper - the RowMapper to use.public void setRowSetFactory(RowSetFactory rowSetFactory)
rowSetFactory. Used to create a RowSet implemenation. By default the
DefaultRowSetFactory is used.rowSetFactory - the RowSetFactory to use.public void setSkippedRowsCallback(RowCallbackHandler skippedRowsCallback)
skippedRowsCallback - will be called for each one of the initial skipped lines before any items are read.public void setEndAfterBlankLines(int endAfterBlankLines)