Giter Club home page Giter Club logo

poi.scala's People

Contributors

apinion avatar badnotes avatar bitdeli-chef avatar daneko avatar dependabot[bot] avatar folone avatar frosforever avatar github-actions[bot] avatar kazuyamiyashita avatar mostr avatar ocadaruma avatar remk avatar rhyskeepence avatar rintcius avatar scala-steward-bot avatar t3hnar avatar vietnc avatar xuwei-k avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

poi.scala's Issues

Use more IO

Make the creation of Workbook from path (def apply on object Workbook) return IO Workbook instead of Workbook.

Export to Exel from an Exel template with poi

My expectation is to reuse some macro script inside a template to format the data for user purpose.
Current version is not supported to export exel from an template.
By reusing the current library, I got over it by something like this:


import info.folone.scala.poi._
import ss.usermodel.{WorkbookFactory, Cell => POICell, Row => POIRow, Workbook => POIWorkbook}

..
/*
* @param filePath: link to your template
* @param rows: set of Row data to export
*/
 def addDataToExelTemplate(filePath:String, rows: Set[Row])
  : POIWorkbook =  {

    val template: InputStream = getClass.getResourceAsStream(filePath)
    val wb   = WorkbookFactory.create(template)

    val data = for {
      i     ← 0 until wb.getNumberOfSheets
      sheet = wb.getSheetAt(i) if (sheet != null)
      k     ← 0 to sheet.getLastRowNum
      row   = sheet.getRow(k) if (row != null)

      j     ← 0 until row.getLastCellNum
      cell  = row.getCell(j) if (cell != null)
    } yield (sheet, row, cell)
    
    val lastRowNum = wb.getSheetAt(0).getLastRowNum +1
   // append our data to end of the first sheet.
    rows foreach { rw ⇒
      val Row((index), (cells)) = rw
      val row = wb.getSheetAt(0) createRow index + lastRowNum
      cells foreach { cl ⇒
        val poiCell = row createCell cl.index
        setPoiCell(row, cl, poiCell)
      }
    }
   //return this workbook to use for exporting.
   // for example: wb.write(outputStream)
    wb
  }
/*
* this code is reused from lib.
*/
private def setPoiCell(row: POIRow, cell: Cell, poiCell: POICell): Unit {
{
    cell match {
      case StringCell(index, data)  ⇒
        poiCell.setCellValue(data)
        val height = data.split("\n").size * row.getHeight
        row setHeight height.asInstanceOf[Short]
      case BooleanCell(index, data) ⇒ poiCell.setCellValue(data)
      case NumericCell(index, data) ⇒ poiCell.setCellValue(data)
      case FormulaCell(index, data) ⇒ poiCell.setCellFormula(data)
      case styledCell@StyledCell(_, _) ⇒ {
        setPoiCell(row, styledCell.nestedCell, poiCell)
      }
    }
  }
}
..

Hope this help someone who met the same expectation, or give author any idea to improve the product.

poi-scala with scalaz 7.1.0

I'm using scalaz 7.1.0 and since I've added poi-scala I cannot run my tests. I get this error:

java.lang.IncompatibleClassChangeError: Found class scalaz.Memo, but interface was expected

I've searched online but all the solutions ahve to do with adding specific versions of specs2, which I am not deliberatly using. Is there anyway to solve this?

How to read the data from the sheet?

I read your documentation about scala poi, but I can't find out how to actually read the data from the sheet. For instance I want to read all from the document and print it out. May be I just don't understand the dsl. Could you help me?

If business company org can use this package?

Hi the package owner:
this package is great ,can suit the condition what my company business.but I want to know if it can use in business company? I have not see the license about this.
wait for you replay
kind regards

Setting column width without using autoSizeColumns

Great project, we've been using it in production for half a year now.

Is it possible to add some functionality to set column width without auto sizing features? Auto sizing columns requires a frame buffer and is really expensive for large sheets.

Release for poi 5.2.0 dependency

As of Apache poi 5.2.0, the dependency on log4j-api has been updated to 2.17.1.
It seems that the master branch has already been updated to poi 5.2.0, so could you please release it?

Reading workbook using File instead of InputStream

Looking through comments in the POI javadoc, it seems it is recommended to use a File rather than InputStream in WorkbookFactory. I've noticed Workbook.apply uses InputStream everywhere even when a filePath is passed as arguments. Is this worthy of a change or is InputStream indeed the correct choice?

Open existing workbook for update

Hi,

I would like to discuss how to add the possibility of opening an existing workbook template to edit, instead of creating a new one each time.

I can see that Workbook.scala would have to be changed:

  • add an apply method which takes a filename and "something" around line 78
  • change line11 to read from an inputstream when the filename exists

I am not sure what "something" should be :

  • A list of sheets each with a list of row each with a list of cells though.
    Then the wrapper would have to test if the sheet exists or not and use create or getSheet accordingly, same for row and cell
  • A list of transformations to be executed against the workbook ...

How would you go about it ?

library not in maven repository

I want use Poi Scala library in the my Play framework project, And I added Poi Scala library to libraryDependencies in build.sbt:

libraryDependencies ++= Seq(
jdbc,
anorm,
cache,
"info.folone" %% "poi-scala" % "0.11",
"com.typesafe.slick" %% "slick" % "2.0.0-RC1",
"com.typesafe.slick" %% "slick-testkit" % "2.0.0-RC1" % "test",
"com.typesafe.play" %% "play-slick" % "0.5.0.8",
"com.novocode" % "junit-interface" % "0.10" % "test",
"ch.qos.logback" % "logback-classic" % "0.9.28" % "test",
"postgresql" % "postgresql" % "9.1-901.jdbc4",
"postgresql" % "postgresql" % "9.1-901.jdbc4" % "test",
"org.webjars" %% "webjars-play" % "2.2.0",
"org.webjars" % "bootstrap" % "2.3.1"
)
by instruction Poi Scala

but, when I do command "play update" appear following error:

[warn] module not found: info.folone#poi-scala_2.10;0.11
[warn] ==== local: tried
[warn] c:\tools\play-2.2.1\repository\local\info.folone\poi-scala_2.10\0.11\iv
ys\ivy.xml

[warn] ==== Maven2 Local: tried
[warn] file:/C:/Users/boyfox/.m2/repository/info/folone/poi-scala_2.10/0.11/po
i-scala_2.10-0.11.pom
[warn] ==== public: tried
[warn] http://repo1.maven.org/maven2/info/folone/poi-scala_2.10/0.11/poi-scala
_2.10-0.11.pom

[warn] ==== Typesafe Releases Repository: tried
[warn] http://repo.typesafe.com/typesafe/releases/info/folone/poi-scala_2.10/0
.11/poi-scala_2.10-0.11.pom

I like this project, and...

Dependencies haven't been updated since sbt 0.13.x; some artifacts required for running sbt test are unavailable.

After updating project/build.properties...

[info] Loading global plugins from /Users/ITMETHO/.sbt/0.13/plugins
[info] Loading project definition from /Users/ITMETHO/Developer/poi.scala/project
[info] Compiling 1 Scala source to /Users/ITMETHO/Developer/poi.scala/project/target/scala-2.10/sbt-0.13/classes...
[info] Resolving org.scala-sbt#interface;0.13.17 ...
[warn] 	[FAILED     ] org.scala-sbt#compiler-interface;0.13.17!compiler-interface.jar(src):  (0ms)
[warn] ==== local: tried
[warn]   /Users/ITMETHO/.ivy2/local/org.scala-sbt/compiler-interface/0.13.17/srcs/compiler-interface-sources.jar
[warn] ==== public: tried
[warn]   https://repo1.maven.org/maven2/org/scala-sbt/compiler-interface/0.13.17/compiler-interface-0.13.17-sources.jar
[warn] ==== local-preloaded-ivy: tried
[warn]   /Users/ITMETHO/.sbt/preloaded/org.scala-sbt/compiler-interface/0.13.17/srcs/compiler-interface-sources.jar
[warn] ==== local-preloaded: tried
[warn]   file:////Users/ITMETHO/.sbt/preloaded/org/scala-sbt/compiler-interface/0.13.17/compiler-interface-0.13.17-sources.jar
[warn] 	::::::::::::::::::::::::::::::::::::::::::::::
[warn] 	::              FAILED DOWNLOADS            ::
[warn] 	:: ^ see resolution messages for details  ^ ::
[warn] 	::::::::::::::::::::::::::::::::::::::::::::::
[warn] 	:: org.scala-sbt#compiler-interface;0.13.17!compiler-interface.jar(src)
[warn] 	::::::::::::::::::::::::::::::::::::::::::::::
sbt.InvalidComponent: Couldn't retrieve source module: org.scala-sbt:compiler-interface:0.13.17:component

https://mvnrepository.com/artifact/org.scala-sbt/compiler-interface lists no versions 0.13.x of compiler-interface, but 0.1.0-M3 references the 0.13 license.

Updating SBT to v1.2.4 results in dependency failures for sbt-pgp, ensime-sbt, and scalastyle-sbt-plugin; fixing these causes errors which must be f of deprecation.

[error] object Build extends Build {
[error]                      ^
[error] /Users/ITMETHO/Developer/poi.scala/project/Build.scala:28:13: type mismatch;
[error]  found   : Some[sbt.librarymanagement.MavenRepository]
[error]  required: sbt.Task[Option[sbt.librarymanagement.Resolver]]
[error]         Some("snapshots" at nexus + "content/repositories/snapshots")
[error]

Sheet's should always be in insertion order

A question was asked in #52 ( But how to order sheets by name or by adding order?) and this code for sorting by name was given:

val sheets: List[Sheet] = ...

Workbook(TreeSet(sheets : _*)(Ordering.fromLessThan[Sheet](_.name < _.name)))

It got me to thinking, when wouldn't sheets need to be in insertion order? I can't think of any reason a user would want there sheet order to be randomized.

Would it be better to use a data type that uses insertion order by default? In any case:

How can I achieve preserving insertion order for Sheets with poi.scala today?

Thanks!

File is not output

I have called safeToFile and called unsafePerformIO on the result of that call - but no file has been written to the file path I supplied!

scalaz.Free$Gosub cannot be cast to scala.Tuple2 error thrown running examples

Scala version: 2.11.8
Dependencies added

val dependencies = Seq(
  "com.typesafe.scala-logging" %% "scala-logging-slf4j" % "2.1.2",
  "org.scalaz" %% "scalaz-core" % "7.3.0-M4",
...
  "org.apache.poi" % "poi-ooxml" % "3.14",
  "info.folone" %% "poi-scala" % "0.14")

Got the following error

scala> sheetOne.safeToFile(path).fold(ex => throw ex, identity).unsafePerformIO
java.lang.ClassCastException: scalaz.Free$Gosub cannot be cast to scala.Tuple2
  at scalaz.effect.IO$class.unsafePerformIO(IO.scala:22)
  at scalaz.effect.IOFunctions$$anon$6.unsafePerformIO(IO.scala:227)
  ... 42 elided

while trying to execute the sample code displayed

scala> import info.folone.scala.poi._
import info.folone.scala.poi._

scala> import scalaz._
import scalaz._

scala> import syntax.monoid._
import syntax.monoid._

scala> import syntax.foldable._
import syntax.foldable._

scala> import std.list._
import std.list._

scala> val sheetOne = Workbook {
   Set(Sheet("name") {
     Set(Row(1) {
       Set(NumericCell(1, 13.0/5), FormulaCell(2, "ABS(A1)"))
     },
     Row(2) {
       Set(StringCell(1, "data"), StringCell(2, "data2"))
     })
   },
   Sheet("name2") {
     Set(Row(2) {
       Set(BooleanCell(1, true), NumericCell(2, 2.4))
     })
   })
 }
sheetOne: info.folone.scala.poi.Workbook = Workbook(Set(Sheet ("name")(Set(Row (1)(Set(NumericCell(1, 2.6), FormulaCell(2, "=ABS(A1)"))), Row (2)(Set(StringCell(1, "data"), StringCell(2, "data2"))))), Sheet ("name2")(Set(Row (2)(Set(BooleanCell(1, true), NumericCell(2, 2.4)))))))

scala> val path = "/tmp/workbook.xls"
path: String = /tmp/workbook.xls

scala> sheetOne.safeToFile(path).fold(ex  throw ex, identity).unsafePerformIO

Provide generic extractor for ``Cell``

It would be useful to have a generic extractor which could delegate to specialized extractors. For example:

object Cell {
  def unapply(cell: Cell): Option[(Int, Any)] =
    cell match {
      case StringCell(index, data)  => Some((index, data))
      case NumericCell(index, data) => Some((index, data))
      case BooleanCell(index, data) => Some((index, data))
      case FormulaCell(index, data) => Some((index, data))
      case _ => None
    }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.