- 浏览: 2963 次
-
最新评论
文章列表
public class POICell implements ICell {
private Cell cell;
private String key;
private FormulaEvaluator fe;
private IRow row;
private static final Map<String, CellStyle> CACHE = new HashMap<String, CellStyle>();
POICell(Cell cell, String key) {
this.cell = cel ...
POIWorkbook,应该通过工厂得到IWorkbook比较合理
public class POIWorkbook implements IWorkbook {
private Workbook wb;
@Override
public ISheet getSheetAt(int index) {
if (wb == null) {
throw new RuntimeException("call read first.");
}
POISheet sheet = new POISheet(wb.getSheetAt(in ...
public class POISheet implements ISheet {
private Sheet sheet;
private IWorkbook wb;
POISheet(Sheet sheet) {
this.sheet = sheet;
}
@Override
public IRow getRow(int index) {
return newPOIRow(sheet.getRow(index));
}
@Override
public Iterator<IRow> iterator() {
...
声明一下:代码仅仅为了一点乐趣,有些地方明知道这样写不好,但是还是懒了。
数据绑定
public interface IRowBinder<T> extends IConstants {
public T bind(IRow row);
}
public interface IRowMarshaller<T> extends IConstants {
public void marshall(IRow row,T t);
}
过滤
public interface ISheetFilter {
public boo ...
某日,同学求助,他们每个月要从一个Excel表格A中获取一些数据,导入到一个统一的Excel B中,Excel B是全量的,每个月追加进去。
其实直接通过POI,比较简单的就可以实现了,但是自己又开始抽筋了,要做一番设计。
封装一下POI吧,这样感觉干净些。
原生的POI少了两个特性,一个是过滤,一个是数据绑定。
我先定义接口:
public interface IWorkbook extends IConstants {
public ISheet getSheetAt(int index);
public ISheet createSheet(String n ...
继续
public interface ICellValue extends Serializable {
public String getString();
public Date getDate();
public Double getDouble();
public Boolean getBoolean();
public Boolean isNumeric();
public Boolean isEmpty();
}
public interface IConstants {
public fi ...