XMLToXML
I- Introduction
The "XMLToExcel" connector allows you to transform an XML file into an Excel file following a given format.
The connector uses the Apache POI library to perform the transformation.
Here is what you can do very easily (You can do much better by making the view much prettier 😊):
Let's get to the heart of the matter.
II- Parameters & Templates
Parameters
You will find the "XMLToExcel" connector in the connectors palette:
Here are the parameters of the "XMLToExcel" connector: - Format: The format that specifies all the visual parameters of the document - Template: A Template file can be specified pre-filled with images / shapes… ==> Parameter not required. - File name: The name of the output file. - Input file: The input must take the form's format.
Templates
The connector will be based on a Template if exist, otherwise it will create a new Excel file. The Template parameter is optional.
III- 1st Example: File with a template containing datas
Template
Below the following Template: An Excel file with two sheets (Preamble and Jobs)
- Preamble :
- Jobs :
The “Jobs” sheet contains a conditional display in the status and duration column: - Status “OK” will be displayed in green - Status “KO” will be displayed in red - status “Warn” will be displayed in orange - Time greater than 500 seconds will be displayed in red.
Output File
In this example, we want to generate this Excel file :
And a filled data table :
Datas will be inserted into the Excel file taking into account the initial format of the Template (including conditional display)
File format
The format file used for this transformation :
<iXDoc>
<styleSheet1 styleSheetName="Preamble" actif="true">
<Preambule type="table">
<Date beginLine="4">
<value column="E"/>
</Date>
<Description>
<value column="E"/>
</Description>
</Preambule>
</styleSheet1>
<styleSheet2 styleSheetName="Jobs" >
<Jobs type="table">
<Job beginLine="3">
<JOBID column="B" formatType="numeric" />
<DESCRIPTION/>
<DURATION formatType="numeric" />
<STARTDATE/>
<STATUSTYPEID formatType="numeric"/>
</Job>
</Jobs>
</styleSheet2>
</iXDoc>
Input File
The input file used for this transformation is :
<styleSheet1>
<Preambule>
<Date>
<value>27/04/2021</value>
</Date>
<Description>
<value>Generated dynamically</value>
</Description>
</Preambule>
</styleSheet1>
<styleSheet2>
<Jobs>
<Job>
<JOBID>227140</JOBID>
<DESCRIPTION>Session 227140 : FTP - R-LIV-076597601-3.XML</DESCRIPTION>
<DURATION>164</DURATION>
<STARTDATE>2021-01-20 13:13:01.0</STARTDATE>
<STATUSTYPEID>0</STATUSTYPEID>
</Job>
<Job>
<JOBID>227141</JOBID>
<DESCRIPTION>Received file : /R-LIV-076597601-3.XML' from : 'FML_REPORT</DESCRIPTION>
<DURATION>130</DURATION>
<STARTDATE>2021-01-20 13:13:01.0</STARTDATE>
<STATUSTYPEID>0</STATUSTYPEID>
</Job>…
</Jobs>…
Note that those datas can be retrieved dynamically from a BDDToXML connector for instance.
Format explanation
The file format and the input file begin with an iXDoc node, followed by "Sheet" type nodes. Each "Sheet" node must contain attribut: type = "Table" or type = "Chart", in the example above, we have the sheet "Preamble" which contains small tables. Here are the properties encountered:
Properties | Description | Example |
---|---|---|
styleSheetName | The name of the Excel document sheet, mandatory value. If the sheet does not exist, the connector created it with the name of the property | styleSheetName= " Preamble" |
actif | Designates whether the page should be active when opening the document or not. This property only exists for "sheet" type tags (which have the "styleSheetName" attribute) | Actif = "true" |
type | The type of the sheet element, either "table" or "chart" | Type= "table" Type= "chart" |
beginLine | The start line on the chosen sheet | beginLine="4" |
column | The start column (in letters) | column= "B" |
formatType | The format type of the file's cell | formatType= "numeric" |
No comments for this page