1
0
Fork
You've already forked Sheet
0
Access Excel spreadsheets in Scala
  • Scala 98.7%
  • Shell 1.3%
2026年02月07日 16:24:27 +01:00
project v0.1.3 -- bump sbt, Scala 3, 2.13 2026年02月07日 16:24:27 +01:00
scripts v0.1.3 -- bump sbt, Scala 3, 2.13 2026年02月07日 16:24:27 +01:00
src v0.1.3 -- bump sbt, Scala 3, 2.13 2026年02月07日 16:24:27 +01:00
.gitignore v0.1.3 -- bump sbt, Scala 3, 2.13 2026年02月07日 16:24:27 +01:00
.travis.yml v0.1.2 -- adds Scala 2.12 support 2016年12月30日 21:54:50 +01:00
build.sbt v0.1.3 -- bump sbt, Scala 3, 2.13 2026年02月07日 16:24:27 +01:00
LICENSE.txt Added licence. 2011年09月30日 12:13:53 +03:00
README.md v0.1.3 -- bump sbt, Scala 3, 2.13 2026年02月07日 16:24:27 +01:00

Sheet

Maven Central

statement

Sheet is a Scala DSL to read and write Excel spreadsheets, based on Apache POI.

Note: This is a fork from George Leontiev (folone)'s original project poi-scala. What I did here is remove the Scalaz dependency, and publish an independent artifact.

building

Builds with sbt against Scala 3, 2.13, 2.12. Run sbt test, or start using sbt console.

linking

"de.sciss" %% "sheet" % v

The current version v is "0.1.3".

Note: There is a stax-api dependency coming from Apache POI. If you experience name conflicts when using sbt-assembly in your project, apply this "simple" sbt code:

assemblyMergeStrategy in assembly := {
 case PathList("javax", "xml", xs @ _*) => MergeStrategy.first
 case x =>
 val oldStrategy = (assemblyMergeStrategy in assembly).value
 oldStrategy(x)
}

getting started

scala> import de.sciss.sheet._
import de.sciss.sheet._
scala> val bookOne = Workbook {
 Set(Sheet("foo") {
 Set(Row(1) {
 Set(NumericCell(1, 13.0/5), FormulaCell(2, "ABS(A1)"))
 },
 Row(2) {
 Set(StringCell(1, "data"), StringCell(2, "data2"))
 })
 },
 Sheet("bar") {
 Set(Row(2) {
 Set(BooleanCell(1, true), NumericCell(2, 2.4))
 })
 })
 }
bookOne: de.sciss.sheet.Workbook = Workbook(Sheet("bar")(Row(2)(BooleanCell(1, true), NumericCell(2, 2.4))), Sheet("foo")(Row(1)(NumericCell(1, 2.6), FormulaCell(2, "=ABS(A1)")), Row(2)(StringCell(1, "data"), StringCell(2, "data2"))))
scala> val path = "/tmp/workbook.xls"
path: String = /tmp/workbook.xls
scala> bookOne.saveToFile(path)
scala> val bookTwo = Workbook {
 Set(Sheet("foo") {
 Set(Row(1) {
 Set(StringCell(1, "newdata"), StringCell(2, "data2"), StringCell(3, "data3"))
 },
 Row(2) {
 Set(StringCell(1, "data"), StringCell(2, "data2"))
 },
 Row(3) {
 Set(StringCell(1, "data"), StringCell(2, "data2"))
 })
 },
 Sheet("bar") {
 Set(Row(2) {
 Set(StringCell(1, "data"), StringCell(2, "data2"))
 })
 })
 }
bookTwo: de.sciss.sheet.Workbook = Workbook(Sheet("bar")(Row(2)(StringCell(1, "data"), StringCell(2, "data2"))), Sheet("foo")(Row(1)(StringCell(1, "newdata"), StringCell(2, "data2"), StringCell(3, "data3")), Row(2)(StringCell(1, "data"), StringCell(2, "data2")), Row(3)(StringCell(1, "data"), StringCell(2, "data2"))))
scala> bookTwo.sheetMap("foo").matrix(rows = 2 to 3, columns = 2 to 3) { 
 case Some(StringCell(_, x)) => x;
 case _ => "n/a"
 } .flatten
res1: scala.collection.immutable.IndexedSeq[String] = Vector(data2, n/a, data2, n/a)
scala> val bookOneReloaded = Workbook.fromFile(path)
bookOneReloaded: de.sciss.sheet.Workbook = Workbook(Sheet("bar")(Row(2)(BooleanCell(1, true), NumericCell(2, 2.4))), Sheet("foo")(Row(1)(NumericCell(1, 2.6), FormulaCell(2, "=ABS(A1)")), Row(2)(StringCell(1, "data"), StringCell(2, "data2"))))
scala> bookOne == bookOneReloaded
res2: Boolean = true