sep4j- 簡單的 Java Excel 進程
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);
本文由用戶 nt0644 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!