**
使用easypoi
**
@Test
public void getChange() throws IOException {
ImportParams params = new ImportParams();
// 源文件存放地址
List<Excels> list = ExcelImportUtil.importExcel(
new File("G:\\a.xlsx"),
Excels.class, params);
int i = 0;
List<ExcelsOut> listOut = new ArrayList<>();
for (Excels excel : list) {
ExcelsOut excelsOut = new ExcelsOut();
excel.setBusId(++i+"");
excelsOut.setBusId(excel.getBusId());
excelsOut.setID(excel.getID());
listOut.add(excelsOut);
}
// 导出
Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams("计算机一班学生","学生"),
ExcelsOut.class, listOut);
// 将流转换成文件
FileOutputStream fos = new FileOutputStream("g:\\b.xls");
workbook.write(fos);
fos.close();
}
- 导入文件,省略get,set
public class Excels {
@Excel(name = "ID")
private String ID;
@Excel(name = "busId")
private String busId;
@Excel(name = "cellphone")
private String cellphone;
导出文件-省略get,set
public class ExcelsOut implements java.io.Serializable {
@Excel(name = "用户ID" ,height = 20, width = 30)
private String ID;
@Excel(name = "会员号",height = 20, width = 30)
private String busId;
@Excel(name = "cellphone",height = 20, width = 30)
private String cellphone;
}


博客主要介绍了easypoi的使用,包括导入文件和导出文件的操作,且在介绍过程中省略了get和set相关内容。

466

被折叠的 条评论
为什么被折叠?



