Excel table to DMN decision table converter
This project has two components:
- A standalone converter to transform Excel worksheets (xlsx files) into DMN decision tables (dmn files), implemented and embeddable in Java.
- A Camunda BPM process engine plugin to enable xlsx deployment as part of process applications. Xlsx files are then converted on the fly to DMN tables.
- Conversion of Excel worksheets to DMN decision tables with inputs, outputs and rules
- Pluggable strategy to determine columns that represent inputs and outputs
- Comes as a Java library that can be embedded into custom applications
- Comes as a command line application to execute standalone
- Comes as a process engine plugin to integrate with process application deployments
- Download the command line tool. It is a runnable jar file, so you need to have Java installed.
- Take an Excel file that contains a decision to convert and place it next to the downloaded jar.
java -jar dmn-xlsx-cli-0.2.0.jar --inputs A,B,C --outputs D,E,F path/to/input/file.xlsx path/to/output/file.dmn. Note that this example assumes the columns A, B, and C are inputs and D, E, F are outputs. You can set these as you like.
- Obtain the dmn table and import it in Camunda modeler or in the online DMN table editor.
To use the Java library, add the following Maven dependency to your project:
<dependency> <groupId>org.camunda.bpm.extension.dmn.xlsx</groupId> <artifactId>dmn-xlsx-converter</artifactId> <version>0.2.0</version> </dependency>
Read Excel file, transform to DMN, write to DMN file:
InputStream xlsxInputStream = ...; // open xlsx file here // convert XlsxConverter converter = new XlsxConverter(); DmnModelInstance dmnModelInstance = converter.convert(inputStream); // write OutputStream dmnOutputStream = ...; // open outputstream to file here Dmn.writeModelToStream(dmnOutputStream, dmnModelInstance);
org.camunda.bpm.dmn.xlsx.XlsxConverter has bean properties that allow configuration of the conversion process. These are:
ioDetectionStrategy: An instance of
org.camunda.bpm.dmn.xlsx.InputOutputDetectionStrategy. The default strategy assumes that all but the last column of the worksheet are inputs and the last column is an output. An instance of
org.camunda.bpm.dmn.xlsx.StaticInputOutputDetectionStrategycan be set to define a static set of input and output columns. Custom strategies can be implemented by implementing the interface
Camunda BPM process engine plugin
The process engine artifact can be obtained via the following Maven coordinates:
<dependency> <groupId>org.camunda.bpm.extension.dmn.xlsx</groupId> <artifactId>dmn-xlsx-process-engine-plugin</artifactId> <version>0.2.0</version> </dependency>
Make sure to make the resulting
org.camunda.bpm.dmn.xlsx:dmn-xlsx-process-engine-plugin artifact available on the process engine's classpath. Then configure the class
org.camunda.bpm.xlsx.plugin.XlsxDmnProcessEnginePlugin as a process engine plugin.
With the plugin in place, xlsx files can be included in a deployment and are automatically recognized and converted into DMN XML at deployment time. To configure conversion for a file
<name>.xlsx, a file
<name>.xlsx.yaml can be included in the deployment. Example yaml contents:
--- inputs: ['A', 'B'] outputs: ['C', 'E']
This declares that the columns A and B are inputs of the decision and C and E are outputs.
Apache License 2.0.
How to contribute
Contributions are welcome at any time. Use github issues to discuss missing features or report bugs, and pull requests to contribute code.