基于poi Excel导出

时间:2019-12-20 12:27:58
【文件属性】:

文件名称:基于poi Excel导出

文件大小:12KB

文件格式:JAR

更新时间:2019-12-20 12:27:58

excel导出

实例:import java.util.Date; import org.xlp.annotation.ExcelOutputed; public class Student { @ExcelOutputed private int id; @ExcelOutputed("姓名") private String name; @ExcelOutputed("生日") private Date timDate; @ExcelOutputed private boolean d; public int getId() { return id; } public void setId(int id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public Date getTimDate() { return timDate; } public void setTimDate(Date timDate) { this.timDate = timDate; } public boolean isD() { return d; } public void setD(boolean d) { this.d = d; } @Override public String toString() { StringBuilder builder = new StringBuilder(); builder.append("Student [id=").append(id).append(", name=") .append(name).append(", timDate=").append(timDate) .append(", d=").append(d).append("]"); return builder.toString(); } } public class Test(){ public static void main(String[] args) { anno(); testMap(); } } public static void anno(){ Student student = new Student(); student.setId(1); student.setName("张三;; "); student.setTimDate(new Date()); Student student1 = new Student(); student1.setId(1); student1.setName("张三1"); student1.setTimDate(new Date()); List list = new ArrayList(); list.add(student); list.add(student1);System.out.println(list); XLPExcelBean xlpExcel = new XLPExcelBean(); xlpExcel.setSheetDatasOfBeans(list); xlpExcel.writeExcel("e:/xxx.xls"); } public static void testMap(){ Map map = new HashMap(); map.put("qq", 12); map.put("s=s", "=ass"); map.put("12", true); map.put(null, null); map.put("date", new Date()); map.put("现金", 20.365); System.out.println(map.keySet().toString()); System.out.println(map.values().toArray()[0]); System.out.println(Calendar.getInstance()); XLPExcel xlpExcel = new XLPExcel(); List> arrayList = new ArrayList>(); arrayList.add(map); xlpExcel.setSheetDatas(arrayList); xlpExcel.writeExcel(new File("e:/xx1.xls")); }


网友评论