excel4j
A java library for reading and writing microsoft office excel file.Thanks to POI.
Getting started
- Define an entity
@Excel
@Sheet("example")
public class Example {
@Cell("testing string")
private String paramStr;
@Cell("testing number")
private Integer paramInt;
@Cell(value="testing date",dateFormat="yyyy-MM-dd")
private Date date;
}
- list to xls
public class Export {
public void export(){
List<Example> list=new ArrayList();
FileOutputStream fout = new FileOutputStream("/test.xls");
fout.write(Excel4j.opsWrite().fromList(list));
fout.close();
}
}
- xls to list
public class Export {
public void export(){
byte[] data=new byte[1];
List<Example> list = Excel4j.opsRead(data)
.toList(Example.class);
}
}