Skip to content

Kaleidocs/merge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kaleidocs/merge

A Clojure wrapper for XDocReport. Works on Open Document Format for Office Applications and Velocity syntax.

Installation

Include Kaleidocs/merge in your project.clj:

Kaleidocs/merge at Clojars

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]])

Usage

Simple structure

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.

Documents with repeated rows in tables (ODT only)

  • Create a table (you can type placeholders directly without the XDocReport extension for LibreOffice / Open Office)

Making template

  • 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"}]})

Result

More information about creating templates (about XDocReport extension for LibreOffice / OpenOffice, too)

Packaging projects that use kaleidocs/merge

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

License

Copyright © 2014 Hoang Minh Thang

Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.

About

Merge ODT/ODS templates from Clojure data structure

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published