POI封装之一

某日,同学求助,他们每个月要从一个Excel表格A中获取一些数据,导入到一个统一的Excel B中,Excel B是全量的,每个月追加进去。

其实直接通过POI,比较简单的就可以实现了,但是自己又开始抽筋了,要做一番设计。

封装一下POI吧,这样感觉干净些。

原生的POI少了两个特性,一个是过滤,一个是数据绑定。

我先定义接口:


public interface IWorkbook extends IConstants {

public ISheet getSheetAt(int index);

public ISheet createSheet(String name);

public ISheet cloneSheet(int index);

public ISheet cloneSheet(String name);

public void removeSheet(String name);

public Iterator<ISheet> iterator();

public Iterator<ISheet> iterator(ISheetFilter filter);

public void write(File file) throws IOException, Exception;

public IWorkbook read(File file) throws IOException, Exception;
}



public interface ISheet extends IConstants {

public IRow getRow(int index);

public Iterator<IRow> iterator();

public Iterator<IRow> iterator(IRowFilter filter);

public IRow createRow(int index);

public String getName();

public ISheet setName(String name);

public IWorkbook getWorkbook();
}



public interface IRow extends IConstants {

public ICell getCell(String x);

public <T> T bind(IRowBinder<T> irb);

public ICell createCell(String x,int cellType);

public ICell createCell(String x);

public <T> void marshall(IRowMarshaller<T> marshaller,T t);

public int getRowNum();

public ISheet getSheet();

}



public interface ICell extends IConstants, Evaluatable {

public final static int CELL_TYPE_NUMERIC = 0;

public final static int CELL_TYPE_STRING = 1;

public final static int CELL_TYPE_FORMULA = 2;

public final static int CELL_TYPE_BLANK = 3;

public final static int CELL_TYPE_BOOLEAN = 4;

public final static int CELL_TYPE_ERROR = 5;

public void setValue(Object value);

public void setValue(Object value, String dataFormat);

public int getType();

public String getKey();

public IRow getRow();

public ICellValue getCellValue();

}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值