Flexi2XML can be used as a conversion tool for transferring data both to and from ABRA Flexi. It can open a file, convert it to XML, apply a conversion script to it, and write out the result — in both directions. For instructions on how to obtain the tool, see the article Downloading Flexi2XML.
More complex conversions from XLS to Flexi
ABRA Flexi has basic import capabilities for XLS (Excel) files built in. For more complex cases — where the column names don't match the record properties, values need to be recalculated, or data needs to be assembled from multiple files — you need to use the Flexi2XML tool.
Converting from Excel
The tool can read both XLS and XLSX files. Let's take the following spreadsheet:
Price list | Customer | Price |
8593026341407 | FLEXI | 1000.0 |
8593026341407 | ARIT | 900.0 |
8593026341407 | VFH | 1050.0 |
8593026341407 | ABRA | 1100.0 |
Converting from XLS to XML
To perform further processing, let's convert the spreadsheet to XML:
flexibee2xml --from-xls soubor.xls --evidence odberatel --to-xml soubor.xml
The result is XML in which the column names become element names:
<?xml version="1.0" encoding="utf-8"?>
<winstrom version="1.0">
<odberatel>
<Ceník>8593026341407</Ceník>
<Odběratel>FLEXI</Odběratel>
<Cena>1000.0</Cena>
</odberatel>
<odberatel>
<Ceník>8593026341407</Ceník>
<Odběratel>ARIT</Odběratel>
<Cena>900.0</Cena>
</odberatel>
</winstrom>
ℹ️ The --evidence parameter only determines the name of the row element. If you omit it, each row is wrapped in a generic <row>.
⚠️ On Linux and macOS, enclose the semicolon in quotes — --delimeter ";". Without them, the shell treats it as a command separator and discards part of the command. (The switch is indeed named --delimeter, with this typo.)
If the column names matched the property names in Flexi XML exactly, we'd be done — that's exactly how working with CSV and XLS works in the REST API. Usually, however, the XML still needs to be adjusted, and that's what XSL transformations are for.
Converting from XML to XML (XSLT)
XSL transformations are a standardized tool, but individual implementations tend to differ. Flexi2XML is therefore built on the same core as ABRA Flexi — which guarantees maximum compatibility.
Let's prepare the conversion script odberatel-in.xslt:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:java="http://xml.apache.org/xalan/java" version="1.0" exclude-result-prefixes="java">
<xsl:output method="xml" indent="yes" encoding="utf-8"/>
<xsl:template match="/winstrom">
<winstrom version="1.0">
<xsl:apply-templates select="odberatel"/>
</winstrom>
</xsl:template>
<xsl:template match="odberatel">
<odberatel>
<firma>code:<xsl:value-of select="java:flexibee.Tool.toUpper(Odběratel)"/></firma>
<cenik>code:<xsl:value-of select="java:flexibee.Tool.toUpper(Ceník)"/></cenik>
<prodejCena>
<xsl:value-of select="Cena"/>
</prodejCena>
</odberatel>
</xsl:template>
</xsl:stylesheet>
There are many introductions to XSLT available — for example The Complete Guide to XSLT (in Czech) or Jirka Kosek's introduction (in Czech). In XSLT, you can iterate (<xsl:for-each/>), use conditions (<xsl:if/>), and index content (<xsl:key/>); however, it isn't classic iterative programming.
We then run the transformation:
flexibee2xml --from-xml soubor.xml --run-xslt odberatel-in.xslt --to-xml vysledek.xml
Or with a single command, skipping the intermediate step:
flexibee2xml --from-xls soubor.xls --evidence odberatel --run-xslt odberatel-in.xslt --to-xml vysledek.xml
The result can then be imported into ABRA Flexi either directly or using batch processing.
Overview of switches
The tool will print the full list itself with the --help parameter. Input and output formats can be combined arbitrarily — so the tool can even convert between two tabular formats without touching the data.
Switch | Meaning |
| Input file and its format. |
| Output file and its format. |
| The name of the row element in the resulting XML; if omitted, |
| Applies an XSL transformation to the data. |
| Optional parameters for XSLT or for batch uploading. |
| Delimiter, encoding, and suppression of the header row for CSV. |
| The name of the MEMO file for the DBF format. |
| Removes duplicate records. |
| Splits large XML into smaller files. |
| Batch uploading based on a configuration file — see Batch processing. |
| Prints the tool's version and an overview of switches. |
💡 Unlike the REST API, which silently ignores unknown parameters, the tool reports a typo in a switch name as Unrecognized option and exits. This way, the error is spotted right away.
A few concluding notes
The resulting XSLT transformation can be saved as a custom transformation directly in the company, and then used from the REST API as well, via the
formatparameter. If you'd like it built directly into Flexi, please contact our support team.Multiple files can also be processed at once — this is handy when you have one CSV or XLS file with invoice headers and another with line items.
Flexi2XML can also be used to split a large XML file into many smaller ones and then upload them one by one.
