A Clojure wrapper for XDocReport. Works on Open Document Format for Office Applications and Velocity syntax.
Include Kaleidocs/merge in your project.clj
:
then also in your project.clj
, add templates engine(s) to dev dependencies:
:profiles
{:dev
{:dependencies
[[fr.opensagres.xdocreport/fr.opensagres.xdocreport.document.odt "1.0.3"]
[fr.opensagres.xdocreport/fr.opensagres.xdocreport.document.ods "1.0.3"]]}}
(You should not add these templates engines to your dependencies. See Packaging section for details.)
In your namespace:
(require '[kaleidocs.merge :refer [merge-doc]])
Create ODT/ODS templates with LibreOffice / OpenOffice. Templates are just normal office files with some placeholders typed directly inside. Follow velocity syntax, something like this:
- In the file
simple-template.odt
:
Hello $name!
Now execute from clojure:
(merge-doc "simple-template.odt"
"simple-output.odt"
{"name" "World"})
- the file
simple-output.odt
should now contain:
Hello World!
ODS templates work the same way.
- Create a table (you can type placeholders directly without the XDocReport extension for LibreOffice / Open Office)
- Let XDocReport do the heavy lifting
(merge-doc "simple-template.odt"
"simple-output.odt"
;; columns
["developers.Name", "developers.Mail", "developers.LastName"]
;; data
{"project" {"Name" "XDocReport"},
"developers"
[{"Name" "ZERR",
"Mail" "[email protected]",
"LastName" "Angelo"},
{"Name" "Leclercq",
"Mail" "[email protected]",
"LastName" "Pascal"}]})
More information about creating templates (about XDocReport extension for LibreOffice / OpenOffice, too)
There is an issue with XDocReport framework that template engines can't be
simply added to :dependencies and run lein uberjar
to produce a
standalone executable jar because java -jar some-project-standalone.jar
should yell:
fr.opensagres.xdocreport.core.XDocReportException: Null template engine. Set template engine with IXDocReport#setTemplateEngine.
The easy way to add these template engines to classpath is to copy them beside the standalone jar. Something like this:
# copy from local maven repository to current directory:
cp ~/.m2/repository/fr/opensagres/xdocreport/fr.opensagres.xdocreport.document.odt/1.0.3/fr.opensagres.xdocreport.document.odt-1.0.3.jar .
cp ~/.m2/repository/fr/opensagres/xdocreport/fr.opensagres.xdocreport.document.ods/1.0.3/fr.opensagres.xdocreport.document.ods-1.0.3.jar .
and run this command instead:
java -classpath "some-project-standalone.jar:fr.opensagres.xdocreport.document.odt-1.0.3.jar:fr.opensagres.xdocreport.document.ods-1.0.3.jar" your.main.namespace
Copyright © 2014 Hoang Minh Thang
Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.