sep4j- 简单的 Java Excel 进程
nt0644
9年前
sep4J: Simple Excel Processing for Java , 通过一次静态方法调用完成 excel <-> List<Bean>之间的转换。 你不必手写任何 POI 相关代码。
支持 Maven.
基本示例
把数据写入Excel
Collection<User> users = Arrays.asList(user1, user2); LinkedHashMap<String, String> headerMap = new LinkedHashMap<String, String>(); headerMap.put("userId", "User Id"); //"userId" is a property of User class. // "User Id" will be the column header in the excel. headerMap.put("firstName", "First Name"); headerMap.put("lastName", "Last Name"); ExcelUtils.save(headerMap, users, outputStream);
解析 Excel
Map<String, String> reverseHeaderMap = new HashMap<String,String>(); reverseHeaderMap.put("User Id", "userId"); //"User Id" is a column header in the excel. //"userId" is the corresponding property of User class. reverseHeaderMap.put("First Name", "firstName"); reverseHeaderMap.put("Last Name","lastName"); List<User> users = ExcelUtils.parseIgnoringErrors(reverseHeaderMap, inputStream, User.class);