icec 1.3 釋出,springboot 整合 jasperreport (ireport)
很多專案都有匯出pdf,word,列印等需求,本次更新給大家帶來jasperreport整合模組。
翻閱網上資料關於springboot整合jasperreport的比較少,很多都是過時的以及重複的文章,很費力。
本次更新對有這方面需求的人來說,有很大參考價值。
本版本功能更新:
-
新增icec-ireport模組
icec-report使用說明
icec 本身就是maven管理的多模組系統;icec-report是新增的用來整合jaserreport的模組,如果需要使用他的功能,那麼就在你的主模組中引入maven依賴;如果不需要,不依賴該模組即可,不影響最終釋出包。 <dependency> <groupId>org.icec</groupId> <artifactId>icec-ireport</artifactId> <version>${icec.version}</version> </dependency>
如何使用?
icec-ireport 裡面已經給出顯示和匯出pdf的案例,對應程式碼 /org/icec/web/ireport/controller/IreportController.java 檢視演示方式:http://localhost:8080/ireport/showpdf(前提是已經將模組整合到專案中)
一些問題?
icec-ireport專案的maven依賴中,有個包會找不到,對,他就是 <dependency> <groupId>org.icec.jasperfont</groupId> <artifactId>msyh</artifactId> <version>1.0</version> </dependency> 這個包,是我自己用jaserreport studio 打的字型包(微軟雅黑),不在maven倉庫,所以報錯了。 需要手動下載jar包,放到本機倉庫中,會用maven的都懂。 msyh-1.0.jar檔案所在路徑icec-ireport/lib/msyh-1.0.jar_改名
jasperreport 中文顯示問題
通過上一步設定,在jasperreport模板中,字型設定成msyh的話,中文就可以正常顯示了。如果想使用其他字型,那麼就要參考官網打包方法,生成新的jar,參考我的辦法,引入到專案中,就可以了。 官網關於自定義字型的url: https://community.jaspersoft.com/wiki/custom-font-font-extension
jasperreport 模板設計工具
推薦使用jasperreport studio (ireport 已過時) 下載地址: https://community.jaspersoft.com/project/jaspersoft-studio
演示截圖: