You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

README-cn.md 13 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. EasyPoi Excel和 Word简易工具类
  2. ===========================
  3. easypoi功能如同名字easy,主打的功能就是容易,让一个没见接触过poi的人员
  4. 就可以方便的写出Excel导出,Excel模板导出,Excel导入,Word模板导出,通过简单的注解和模板
  5. 语言(熟悉的表达式语法),完成以前复杂的写法
  6. 官网: http://opensource.afterturn.cn/
  7. 邮箱: xue315998@qq.com
  8. QQ群: 1群 364192721(满) 2 群116844390
  9. 开发者:魔幻之翼 xf.key@163.com
  10. 优秀团队,承接私活,加微信:13165188222 ,添加备注悟耘
  11. Spring Boot 支持 https://gitee.com/lemur/easypoi-spring-boot-starter
  12. [官网](https://opensource.afterturn.cn)
  13. [英文介绍](https://github.com/jueyue/easypoi/blob/master/README.md) **_希望加个关注_**
  14. **开发指南**
  15. **[https://opensource.afterturn.cn/doc/easypoi.html](http://opensource.afterturn.cn/doc/easypoi.html)**
  16. 下一步计划
  17. - 国际化,翻译文档以及注释
  18. - pdf全部改为模板导出方式
  19. - word模板和excel功能同步
  20. ## cn.afterturn:企业专用easypoi
  21. cn.afterturn:easypoi与Tidelift合作,为您用于构建应用程序的开源依赖项提供商业支持和维护。节省时间,降低风险并改善代码运行状况,同时向维护人员支付所使用的确切依赖项。[了解更多。](https://tidelift.com/subscription/pkg/maven-cn-afterturn-easypoi?utm_source=maven-cn-afterturn-easypoi&utm_medium=referral&utm_campaign=readme)
  22. [用户征集](https://gitee.com/lemur/easypoi/issues/IFDX7)
  23. 按登记顺序展示,如果你正在使用EasyPoi欢迎在 https://gitee.com/lemur/easypoi/issues/IFDX7 登记。仅作为开源参考,不作其它用途
  24. - [博彦科技](http://www.beyondsoft.com)
  25. - [图灵谷北京科技有限公司](http://www.turingoal.com)
  26. - [河南八六三软件股份有限公司](http://www.863soft.com/cn/)
  27. - [网易](http://www.163.com)
  28. - [港华燃气](http://www.towngas.com.cn/)
  29. - [北京易才博普奥管理顾问有限公司](https://www.weifenghr.com/)
  30. - [中投国信(北京)科技发展有限公司](http://sic-credit.cn/)
  31. - [武汉格事化信息技术](https://www.getto1.com/)
  32. - [北京辰森世纪科技股份有限公司](http://www.choicesoft.com.cn/)
  33. - [深圳市太美亚电子科技有限公司](https://www.timeyaa.com/)
  34. 版本介绍
  35. [history.md](https://gitee.com/lemur/easypoi/blob/master/history.md)
  36. 基础示例
  37. [basedemo.md](https://gitee.com/lemur/easypoi/blob/master/basedemo.md)
  38. [测试项目](http://git.oschina.net/lemur/easypoi-test): http://git.oschina.net/lemur/easypoi-test
  39. ---------------------------
  40. EasyPoi的主要特点
  41. --------------------------
  42. 1.设计精巧,使用简单
  43. 2.接口丰富,扩展简单
  44. 3.默认值多,write less do more
  45. 4.AbstractView 支持,web导出可以简单明了
  46. ---------------------------
  47. 什么场景该用哪个方法
  48. ---------------------------
  49. - 导出
  50. 1.正规excel导出 (格式简单,数据量可以,5W以内吧)
  51. 注解方式: ExcelExportUtil.exportExcel(ExportParams entity, Class<?> pojoClass,Collection<?> dataSet)
  52. 2.不定多少列,但是格式依然简单数据库不大
  53. 自定义方式: ExcelExportUtil.exportExcel(ExportParams entity, List<ExcelExportEntity> entityList,Collection<?> dataSet)
  54. 3.数据量大超过5W,还在100W以内
  55. 注解方式 ExcelExportUtil.exportBigExcel(ExportParams entity, Class<?> pojoClass,IExcelExportServer server, Object queryParams)
  56. 自定义方式: ExcelExportUtil.exportBigExcel(ExportParams entity, List<ExcelExportEntity> excelParams,IExcelExportServer server, Object queryParams)
  57. 4.样式复杂,数据量尽量别大
  58. 模板导出 ExcelExportUtil.exportExcel(TemplateExportParams params, Map<String, Object> map)
  59. 5.一次导出多个风格不一致的sheet
  60. 模板导出 ExcelExportUtil.exportExcel(Map<Integer, Map<String, Object>> map,TemplateExportParams params)
  61. 6.一个模板但是要导出非常多份
  62. 模板导出 ExcelExportUtil.exportExcelClone(Map<Integer, List<Map<String, Object>>> map,TemplateExportParams params)
  63. 7.模板无法满足你的自定义,试试html
  64. 自己构造html,然后我给你转成excel ExcelXorHtmlUtil.htmlToExcel(String html, ExcelType type)
  65. 8.数据量过百万级了.放弃excel吧,csv导出
  66. 注解方式: CsvExportUtil.exportCsv(CsvExportParams params, Class<?> pojoClass, OutputStream outputStream)
  67. 自定义方式: CsvExportUtil.exportCsv(CsvExportParams params, List<ExcelExportEntity> entityList, OutputStream outputStream)
  68. 9.word导出
  69. 模板导出: WordExportUtil.exportWord07(String url, Map<String, Object> map)
  70. 10.PDF导出
  71. 模板导出: TODO
  72. - 导入
  73. 如果想提高性能 ImportParams 的concurrentTask 可以帮助并发导入,仅单行,最小1000
  74. excel有单个的那种特殊读取,readSingleCell 参数可以支持
  75. 1. 不需要检验,数据量不大(5W以内)
  76. 注解或者MAP: ExcelImportUtil.importExcel(File file, Class<?> pojoClass, ImportParams params)
  77. 2. 需要导入,数据量不大
  78. 注解或者MAP: ExcelImportUtil.importExcelMore(InputStream inputstream, Class<?> pojoClass, ImportParams params)
  79. 3. 数据量大了,或者你有特别多的导入操作,内存比较少,仅支持单行
  80. SAX方式 ExcelImportUtil.importExcelBySax(InputStream inputstream, Class<?> pojoClass, ImportParams params, IReadHandler handler)
  81. 4. 数据量超过EXCEL限制,CSV读取
  82. 小数据量: CsvImportUtil.importCsv(InputStream inputstream, Class<?> pojoClass,CsvImportParams params)
  83. 大数据量: CsvImportUtil.importCsv(InputStream inputstream, Class<?> pojoClass,CsvImportParams params, IReadHandler readHandler)
  84. ---------------------------
  85. 关于Excel导出XLS和XLSX区别
  86. ---------------------------
  87. 1.导出时间XLS比XLSX快2-3倍
  88. 2.导出大小XLS是XLSX的2-3倍或者更多
  89. 3.导出需要综合网速和本地速度做考虑^~^
  90. ---------------------------
  91. 几个工程的说明
  92. ---------------------------
  93. 1.easypoi 父包--作用大家都懂得
  94. 2.easypoi-annotation 基础注解包,作用与实体对象上,拆分后方便maven多工程的依赖管理
  95. 3.easypoi-base 导入导出的工具包,可以完成Excel导出,导入,Word的导出,Excel的导出功能
  96. 4.easypoi-web 耦合了spring-mvc 基于AbstractView,极大的简化spring-mvc下的导出功能
  97. 5.sax 导入使用xercesImpl这个包(这个包可能造成奇怪的问题哈),word导出使用poi-scratchpad,都作为可选包了
  98. --------------------------
  99. maven
  100. --------------------------
  101. maven库应该都可以了
  102. SNAPSHOT 版本-很少发布
  103. https://oss.sonatype.org/content/groups/public/
  104. ```xml
  105. <dependency>
  106. <groupId>cn.afterturn</groupId>
  107. <artifactId>easypoi-spring-boot-starter</artifactId>
  108. <version>4.1.3</version>
  109. </dependency>
  110. <dependency>
  111. <groupId>cn.afterturn</groupId>
  112. <artifactId>easypoi-base</artifactId>
  113. <version>4.1.3</version>
  114. </dependency>
  115. <dependency>
  116. <groupId>cn.afterturn</groupId>
  117. <artifactId>easypoi-web</artifactId>
  118. <version>4.1.3</version>
  119. </dependency>
  120. <dependency>
  121. <groupId>cn.afterturn</groupId>
  122. <artifactId>easypoi-annotation</artifactId>
  123. <version>4.1.3</version>
  124. </dependency>
  125. ```
  126. --------------------------
  127. pom说明
  128. --------------------------
  129. word和sax读取的时候才使用,就不是必须的了,请手动引用,JSR303的校验也是可选的,PDF的jar也是可选的
  130. ```xml
  131. <!-- sax 读取时候用到的 -->
  132. <dependency>
  133. <groupId>xerces</groupId>
  134. <artifactId>xercesImpl</artifactId>
  135. <version>${xerces.version}</version>
  136. <optional>true</optional>
  137. </dependency>
  138. <dependency>
  139. <groupId>org.apache.poi</groupId>
  140. <artifactId>poi-scratchpad</artifactId>
  141. <version>${poi.version}</version>
  142. <optional>true</optional>
  143. </dependency>
  144. <!-- Word 需要使用 -->
  145. <dependency>
  146. <groupId>org.apache.poi</groupId>
  147. <artifactId>ooxml-schemas</artifactId>
  148. <version>1.3</version>
  149. <optional>true</optional>
  150. </dependency>
  151. <!-- 校验,下面两个实现 -->
  152. <dependency>
  153. <groupId>org.hibernate</groupId>
  154. <artifactId>hibernate-validator</artifactId>
  155. <version>5.1.3.Final</version>
  156. <optional>true</optional>
  157. </dependency>
  158. <dependency>
  159. <groupId>org.apache.bval</groupId>
  160. <artifactId>org.apache.bval.bundle</artifactId>
  161. <version>1.1.0</version>
  162. </dependency>
  163. <!-- PDF -->
  164. <dependency>
  165. <groupId>com.itextpdf</groupId>
  166. <artifactId>itextpdf</artifactId>
  167. <version>5.5.6</version>
  168. <optional>true</optional>
  169. </dependency>
  170. <dependency>
  171. <groupId>com.itextpdf</groupId>
  172. <artifactId>itext-asian</artifactId>
  173. <version>5.2.0</version>
  174. <optional>true</optional>
  175. </dependency>
  176. ```
  177. -----------------
  178. Test 测试覆盖率
  179. ----------------
  180. |包|类|方法|行|
  181. |----|----|----|----|
  182. cn|100% (0/0)|100% (0/0)|100% (0/0)
  183. cn.afterturn|100% (0/0)|100% (0/0)|100% (0/0)
  184. cn.afterturn.easypoi|0% (0/1)|0% (0/1)|0% (0/3)
  185. cn.afterturn.easypoi.cache|100% (6/6)|83% (10/12)|60% (40/66)
  186. cn.afterturn.easypoi.cache.manager|100% (3/3)|62% (5/8)|54% (29/53)
  187. cn.afterturn.easypoi.configuration|0% (0/2)|0% (0/1)|0% (0/5)
  188. cn.afterturn.easypoi.entity|100% (1/1)|83% (15/18)|66% (26/39)
  189. cn.afterturn.easypoi.entity.vo|100% (0/0)|100% (0/0)|100% (0/0)
  190. cn.afterturn.easypoi.excel|100% (3/3)|73% (19/26)|59% (44/74)
  191. cn.afterturn.easypoi.excel.annotation|100% (0/0)|100% (0/0)|100% (0/0)
  192. cn.afterturn.easypoi.excel.entity|83% (5/6)|66% (85/127)|63% (185/290)
  193. cn.afterturn.easypoi.excel.entity.enmus|100% (3/3)|88% (8/9)|92% (13/14)
  194. cn.afterturn.easypoi.excel.entity.params|100% (6/6)|84% (94/111)|75% (160/211)
  195. cn.afterturn.easypoi.excel.entity.result|100% (2/2)|76% (16/21)|65% (26/40)
  196. cn.afterturn.easypoi.excel.entity.sax|100% (1/1)|33% (2/6)|45% (5/11)
  197. cn.afterturn.easypoi.excel.entity.vo|100% (1/1)|100% (1/1)|100% (3/3)
  198. cn.afterturn.easypoi.excel.export|100% (2/2)|94% (17/18)|84% (202/238)
  199. cn.afterturn.easypoi.excel.export.base|100% (2/2)|97% (33/34)|88% (353/399)
  200. cn.afterturn.easypoi.excel.export.styler|100% (4/4)|86% (19/22)|97% (122/125)
  201. cn.afterturn.easypoi.excel.export.template|100% (3/3)|95% (43/45)|92% (422/457)
  202. cn.afterturn.easypoi.excel.graph|100% (0/0)|100% (0/0)|100% (0/0)
  203. cn.afterturn.easypoi.excel.graph.builder|0% (0/1)|0% (0/8)|0% (0/92)
  204. cn.afterturn.easypoi.excel.graph.constant|100% (0/0)|100% (0/0)|100% (0/0)
  205. cn.afterturn.easypoi.excel.graph.entity|0% (0/3)|0% (0/26)|0% (0/49)
  206. cn.afterturn.easypoi.excel.html|100% (2/2)|92% (24/26)|84% (242/287)
  207. cn.afterturn.easypoi.excel.html.css|100% (2/2)|100% (10/10)|94% (166/175)
  208. cn.afterturn.easypoi.excel.html.css.impl|100% (6/6)|60% (9/15)|74% (111/149)
  209. cn.afterturn.easypoi.excel.html.entity|100% (0/0)|100% (0/0)|100% (0/0)
  210. cn.afterturn.easypoi.excel.html.entity.style|100% (3/3)|100% (53/53)|100% (87/87)
  211. cn.afterturn.easypoi.excel.html.helper|80% (4/5)|77% (24/31)|67% (154/228)
  212. cn.afterturn.easypoi.excel.imports|100% (2/2)|92% (26/28)|79% (361/454)
  213. cn.afterturn.easypoi.excel.imports.base|100% (1/1)|100% (9/9)|89% (102/114)
  214. cn.afterturn.easypoi.excel.imports.sax|100% (2/2)|100% (8/8)|70% (56/80)
  215. cn.afterturn.easypoi.excel.imports.sax.parse|100% (1/1)|77% (7/9)|58% (44/75)
  216. cn.afterturn.easypoi.exception|100% (0/0)|100% (0/0)|100% (0/0)
  217. cn.afterturn.easypoi.exception.excel|50% (1/2)|20% (3/15)|18% (6/32)
  218. cn.afterturn.easypoi.exception.excel.enums|50% (1/2)|44% (4/9)|40% (9/22)
  219. cn.afterturn.easypoi.exception.word|0% (0/1)|0% (0/3)|0% (0/6)
  220. cn.afterturn.easypoi.exception.word.enmus|0% (0/1)|0% (0/4)|0% (0/10)
  221. cn.afterturn.easypoi.handler|100% (0/0)|100% (0/0)|100% (0/0)
  222. cn.afterturn.easypoi.handler.impl|100% (1/1)|33% (2/6)|44% (4/9)
  223. cn.afterturn.easypoi.handler.inter|100% (0/0)|100% (0/0)|100% (0/0)
  224. cn.afterturn.easypoi.hanlder|0% (0/1)|0% (0/1)|0% (0/17)
  225. cn.afterturn.easypoi.pdf|100% (1/1)|50% (1/2)|33% (1/3)
  226. cn.afterturn.easypoi.pdf.entity|100% (1/1)|52% (10/19)|47% (17/36)
  227. cn.afterturn.easypoi.pdf.export|100% (1/1)|100% (14/14)|85% (131/153)
  228. cn.afterturn.easypoi.pdf.styler|100% (1/1)|100% (4/4)|56% (9/16)
  229. cn.afterturn.easypoi.test|100% (0/0)|100% (0/0)|100% (0/0)
  230. cn.afterturn.easypoi.test.en|100% (3/3)|93% (15/16)|93% (31/33)
  231. cn.afterturn.easypoi.test.entity|91% (11/12)|50% (62/122)|57% (117/202)
  232. cn.afterturn.easypoi.test.entity.check|100% (2/2)|50% (8/16)|69% (18/26)
  233. cn.afterturn.easypoi.test.entity.groupname|75% (3/4)|46% (25/54)|52% (48/92)
  234. cn.afterturn.easypoi.test.entity.img|100% (1/1)|100% (8/8)|100% (16/16)
  235. cn.afterturn.easypoi.test.entity.samename|100% (1/1)|100% (6/6)|100% (10/10)
  236. cn.afterturn.easypoi.test.entity.statistics|100% (1/1)|100% (12/12)|100% (19/19)
  237. cn.afterturn.easypoi.test.entity.temp|80% (4/5)|94% (32/34)|38% (52/134)
  238. cn.afterturn.easypoi.test.web|100% (0/0)|100% (0/0)|100% (0/0)
  239. cn.afterturn.easypoi.test.web.cfg|0% (0/1)|0% (0/1)|0% (0/4)
  240. cn.afterturn.easypoi.tohtml|0% (0/1)|0% (0/4)|0% (0/13)
  241. cn.afterturn.easypoi.util|100% (11/11)|85% (84/98)|73% (668/908)
  242. cn.afterturn.easypoi.view|0% (0/13)|0% (0/27)|0% (0/376)
  243. cn.afterturn.easypoi.word|100% (1/1)|33% (1/3)|20% (1/5)
  244. cn.afterturn.easypoi.word.entity|100% (2/2)|44% (4/9)|45% (27/60)
  245. cn.afterturn.easypoi.word.entity.params|50% (1/2)|22% (5/22)|14% (8/56)
  246. cn.afterturn.easypoi.word.parse|100% (1/1)|91% (11/12)|94% (97/103)
  247. cn.afterturn.easypoi.word.parse.excel|100% (2/2)|90% (10/11)|70% (95/135)