鉴于 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")
}
}