Last active
April 11, 2018 02:21
-
-
Save BadUncleX/1396c3b3d12b0f94176bba21c28655d2 to your computer and use it in GitHub Desktop.
jxls in Clojure [excel process clj] from: http://bit.ly/2GJ72aF
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:dependencies [[org.clojure/clojure "1.8.0"] | |
[org.jxls/jxls "2.4.2"] | |
[org.jxls/jxls-poi "1.0.13" :exclusions [org.jxls/jxls]]]) | |
(import [org.jxls.util JxlsHelper]) | |
(import [org.jxls.common Context]) | |
(require '(clojure.java [io :as io])) | |
;; http://jxls.sourceforge.net/xls/object_collection_template.xls | |
(def io (io/input-stream "object_collection_template.xls")) | |
(def os (io/output-stream "out.xls")) | |
;; keys and values must be strings, yhey are formatted as per template. | |
(def employees [ { "name" "Kris" } { "name" "Chris" } ]) | |
(def context (Context.)) | |
(.putVar context "employees" employees) | |
(def helper (JxlsHelper/getInstance)) | |
(.processTemplate helper io os context) | |
;; If you try and do `.processTemplate` twice with the same io streams you get `java.lang.IllegalStateException: Cannot load XLS transformer. Please make sure a Transformer implementation is in classpath`. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment