Pet*_*ler 19 excel scala apache-poi
我想使用Apache POI在Scala应用程序中读取/创建Excel文件.当然,我可以直接使用POI库,毕竟它是Java,但我想让Scala感觉到.那么是否有一个Scala包装器带来了Scala的感觉(使用隐式转换),即某种"Scala-POI-DSL"免费提供?
fol*_*one 13
感谢Dave Griffith的回答,我已经破解了与他的DSL类似的东西.
Workbook {
Sheet("name") {
Row(1) {
Cell(1, "data") :: Cell(2, "data2") :: Nil
} ::
Row(2) {
Cell(1, "data") :: Cell(2, "data2") :: Nil
} :: Nil
} ::
Sheet("name2") {
Row(2) {
Cell(1, "data") :: Cell(2, "data2") :: Nil
} :: Nil
} :: Nil
}.save("/home/path/ok.xls")
Run Code Online (Sandbox Code Playgroud)
代码可以在这里找到.
Nor*_*dyk 10
鉴于Scala缺乏先进的开源电子表格包装器,我已经开始开发Spoiwo:https://github.com/norbert-radyk/spoiwo.它允许生成XSSFWorkbook并支持POI功能的重要子集.
它仍然需要一些文档,但下面应该大致了解它的功能:
使用Spoiwo的简单电子表格示例:
object GettingStartedExample {
val headerStyle =
CellStyle(fillPattern = CellFill.Solid, fillForegroundColor = Color.AquaMarine, fillBackgroundColor = Color.AquaMarine, font = Font(bold = true))
val gettingStartedSheet = Sheet(name = "Some serious stuff")
.withRows(
Row(style = headerStyle).withCellValues("NAME", "BIRTH DATE", "DIED AGED", "FEMALE"),
Row().withCellValues("Marie Curie", new LocalDate(1867, 11, 7), 66, true),
Row().withCellValues("Albert Einstein", new LocalDate(1879, 3, 14), 76, false),
Row().withCellValues("Erwin Shrodinger", new LocalDate(1887, 8, 12), 73, false)
)
.withColumns(
Column(index = 0, style = CellStyle(font = Font(bold = true)), autoSized = true)
)
def main(args: Array[String]) {
gettingStartedSheet.saveAsXlsx("C:\\Reports\\getting_started.xlsx")
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9193 次 |
| 最近记录: |