如何從Play Framework v2.x(Scala)生成Excell報告。我發現有一個Play-Excel模塊,但它支持PlayFramework v1.0。有沒有適合v2.x的東西?Excel Writer Module for Play Framework v2.x
2
A
回答
1
最後我選擇使用Spoiwo. Scala Wrapper for Apache POI。它有一個簡潔的入門指南。但是,PlayFramework沒有例子。
這是我的快速和骯髒的黑客從案例類生成簡單的報告。
def generateReportXLSX(waybillId: Long) = Action{ implicit request =>
val headerStyle =
CellStyle(fillPattern = CellFill.Solid, fillForegroundColor = Color.DarkGrey, fillBackgroundColor = Color.AquaMarine, font = Font(bold = true))
val listItems: List[Item] = Items.findByWaybillId(waybillId)
val listRows = listItems.map{ item =>
Row().withCellValues(item.id.getOrElse(1), item.itemCode, item.senderName.getOrElse(""))
}
val gettingStartedSheet = Sheet(name = "Накладная ")
.withRows(listRows)
.withColumns(
Column(index = 0, style = CellStyle(font = Font(bold = true)), autoSized = true)
)
gettingStartedSheet.saveAsXlsx("/home/user/dumps/"+waybillId+".xlsx")
Ok.sendFile(new File(("/home/user/dumps/"+waybillId+".xlsx")))
}
相關問題
- 1. Ebean從Play 2 Module for Java中缺失
- 2. Play Framework 2.1.x CascadeType.DETACH
- 3. Scala插件for play framework 2
- 4. 任何CMS for Play Framework?
- 5. 無法配置Ebean Play Framework 2.5.x
- 6. Rythm模板引擎優於Japid for Play Framework 1.x?
- 7. Redis for Java Play 2.x?
- 8. AttributeError:'module'對象沒有屬性'writer'
- 9. 如何修改play play framework 2.4.x中的java play i18n lang?
- 10. 多個數據庫與Play Framework 2.1.x
- 11. Play Framework 2.2.x恢復平面圖
- 12. Pdf Writer for Rails 3
- 13. Play Framework 2 slugify
- 14. Mahana Module for CodeIgniter
- 15. QueryDSL和Play Framework
- 16. Play Framework + SecureSocial:java.lang.NoSuchMethodError:securesocial.controllers.ReverseLoginPage.authenticate
- 17. Play Framework和DB2
- 18. express.js form-module for mongoose
- 19. Atlasian Bamboo 5.x是否兼容Play Framework 2.x
- 20. Play Framework Regex CORS
- 21. Play Framework和Threadpools
- 22. Play Framework CRUD
- 23. Play Framework和scala.tools.nsc
- 24. Play Framework 2 HornetQ
- 25. Play Framework 2.4 Ebean
- 26. Play Framework + tomcat
- 27. akka with play framework
- 28. Play Framework - save()
- 29. DTO in Play Framework
- 30. play-framework [2.0] HTTPS
我想你將不得不使用apche的POI,寫自己,或者你可以使用'dynamicreports'(http://www.dynamicreports.org),並出口到XLS - HTTP://www.dynamicreports .org/examples/excelreport1 – 2015-02-24 11:39:32
感謝您的回覆!我有什麼需要使用Apache Poi自行編寫的? – 2015-02-24 11:53:24
Poi提供低級別的API來創建具有極大靈活性和控制力的Excel文檔,但您也可以查看'dynamicreports'選項。 – 2015-02-24 12:14:34