1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| public class ExcelHelperTest { @Test public void test() { List<Map<Object,Object>> rows = new LinkedList<>(); Map<Object,Object> content = new HashMap<>(); content.put("性别","女"); content.put("年龄","53"); content.put("日期","2018-09-01"); content.put("金额","20.65"); rows.add(content); Map<Object,Object> content1 = new HashMap<>(); content1.put("性别","男"); content1.put("年龄","15"); content1.put("日期","2018-10-01"); content1.put("金额","240.05"); rows.add(content1); Map<String,String> ftype = new HashMap<>(); ftype.put("性别",""); ftype.put("年龄","int"); ftype.put("日期","date"); ftype.put("金额","decimal"); ExcelHelper.exportExcel("test.xls","title",rows,ftype); ExcelHelper.exportExcel("test.xlsx","title",rows,ftype); } }
|