tomfaulhaber / excel-templates

Create Excel workbooks from Clojure code using templates and plain old data
Eclipse Public License 1.0
152 stars 20 forks source link

RowFlushedException on render-to-file with more than 100 rows #33

Open dpetranek opened 8 years ago

dpetranek commented 8 years ago

When I run render-to-file on datasets longer than 100 rows, I get a RowFlushed Exception:

(render-to-file
     "templates/test.xlsx"
     "repltest.xlsx"
     {"Sheet1" {0 (mapv #(conj [] %) (range 101))}})

=> ; RowFlushedException Row 0 has been flushed, cannot evaluate all cells org.apache.poi.xssf.streaming.SXSSFFormulaEvaluator.evaluateAllFormulaCells (SXSSFFormulaEvaluator.java:117)

I'm using a blank .xlsx workbook as the template, so there shouldn't be any problem with the SXSSFFormulaEvaluator.

If I change (range 101) above to (range 100), it works as expected.

tomfaulhaber commented 8 years ago

Ahh, I think that this is a side-effect of the change we made in #12. I'm going to back that out and see if I can't figure out another way to solve that. In the meantime, you might try release 0.3.0 and see if that works better for you.

dpetranek commented 8 years ago

Thanks for the quick reply! Unfortunately, switching back to 0.3.0 is giving me guff - I'm getting an unfamiliar stack trace every time I try to compile - https://www.refheap.com/118065

I've got this in the project.clj dependencies: [com.infolace/excel-templates "0.3.0"] And this is in the namespace declaration of the file where I use it:

(ns emv.routes.report
  (:require [excel-templates.build :as excel]))
tomfaulhaber commented 8 years ago

@dpetranek That looks like you've got a mixed up class path. It says that chart.clj is looking for something from Apache Commons that wasn't added until 0.3.2. I checked the git history and clojars and I think this is right.

Is there some way that you have a version of chart.clj from master or 0.3.3 on your classpath?

dpetranek commented 8 years ago

Thanks Tom. I finally got round to picking this back up, and deleting my target/classes folder cleared it up the ExceptionInInitializerError that was being thrown before. However now when I try to render-to-file, it doesn't write to disk or throw an error:

(excel-writer/render-to-file
                    "resources/test.xlsx"
                    "repltest.xlsx"
                    {"Sheet1" {0 (mapv #(conj [] %) (range 101))}})

=> nil

It returns nil but doesn't actually create repltest.xlsx. The only change I made was to change my dependency to [com.infolace/excel-templates "0.3.0"].

tomfaulhaber commented 8 years ago

Does it work if you create a single cell A1 on the template with a 0 in it?

dpetranek commented 8 years ago

I'm afraid not.

gwzbenjamin commented 8 years ago

tested with data 46(cols) * 10000 (rows), it will take about 20 minutes to finish rendering, can you take a look and see if this can be make faster? as it only take me about 2 minutes to operate the copy & paste for those data in my excel template.

gwzbenjamin commented 8 years ago

(excel/render-to-file "resources/template.xlsx" "e:/tmp/71_test.xlsx" {"new" {1 (take 10000 rows1)} } ) OutOfMemoryError Java heap space [trace missing]