@At
@Ok("raw")
public File down() throws FileNotFoundException, IOException {
HSSFWorkbook wk=new HSSFWorkbook();
HSSFSheet st=wk.createSheet("用户基本信息");
List<ExcelBean> list = dao.query(ExcelBean.class,null);
for (int i = 0; i < list.size(); i++) {
System.out.println(list.get(i));
HSSFRow row = st.createRow(i);
HSSFCell c1 = row.createCell((short) 0);
HSSFCell c2 = row.createCell((short) 1);
HSSFCell c3 = row.createCell((short) 2);
HSSFCell c4 = row.createCell((short) 3);
c1.setCellValue(list.get(i).getId());
c2.setCellValue(list.get(i).getName());
c3.setCellValue(list.get(i).getSex());
c4.setCellValue(list.get(i).getAge());
}
File file=new File("d:temp/a.xls");
if(!file.exists()) {
System.out.println("文件不存在,創建文件中");
file.createNewFile();
}
FileOutputStream io=new FileOutputStream(file);
wk.write(io);
io.close();
return file;
}
ExcelBean [id=27, name=***, sex=男, age=24]
ExcelBean [id=28, name=***, sex=男, age=23]
ExcelBean [id=29, name=**, sex=女, age=23]
ExcelBean [id=30, name=***, sex=女, age=23]
ExcelBean [id=31, name=***, sex=男, age=24]
ExcelBean [id=32, name=***, sex=男, age=28]
ExcelBean [id=33, name=***, sex=女, age=24]