org.gageot.excel.core
Class BeanCellCallbackHandler

java.lang.Object
  extended by org.gageot.excel.core.BeanCellCallbackHandler
All Implemented Interfaces:
CellCallbackHandler

public class BeanCellCallbackHandler
extends java.lang.Object
implements CellCallbackHandler

CallbackHandler implementation that creates a bean of the given class for each row, representing all columns as bean properties.

Author:
David Gageot
See Also:
ExcelTemplate.read(String,CellCallbackHandler), BeanSetter

Constructor Summary
BeanCellCallbackHandler(java.lang.Class aClass)
           
 
Method Summary
protected  java.lang.Object createBean(java.lang.Class aClazz)
          Create a bean for a given class.
 java.util.List getBeans()
           
 void processCell(org.apache.poi.hssf.usermodel.HSSFCell cell, int rowNum, int columnNum)
          Implementations must implement this method to process each cell of data in the HSSFSheet.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BeanCellCallbackHandler

public BeanCellCallbackHandler(java.lang.Class aClass)
Method Detail

getBeans

public java.util.List getBeans()

processCell

public void processCell(org.apache.poi.hssf.usermodel.HSSFCell cell,
                        int rowNum,
                        int columnNum)
                 throws java.io.IOException,
                        org.springframework.beans.BeansException
Description copied from interface: CellCallbackHandler
Implementations must implement this method to process each cell of data in the HSSFSheet. This method should extract the current value. Exactly what the implementation chooses to do is up to it; a trivial implementation might simply count cells, while another implementation might build an XML document.

Specified by:
processCell in interface CellCallbackHandler
Parameters:
cell - the HSSFCell to process
rowNum - the number of the current row
columnNum - the number of the current column
Throws:
java.io.IOException - if a IOException is encountered getting column values (that is, there's no need to catch IOException)
org.springframework.beans.BeansException

createBean

protected java.lang.Object createBean(java.lang.Class aClazz)
                               throws org.springframework.beans.BeansException
Create a bean for a given class. Default strategy is to create an empty bean calling its empty constructor. This method can be overridden for a different strategy.

Parameters:
clazz - the class of the bean to create
Throws:
org.springframework.beans.BeansException


Copyright © 2007 gageot.net. All Rights Reserved.