Wiki source code of XMLToExcel

Last modified by Achraf El Kari on 2022/07/25 12:50

Show last authors
1 {{box cssClass="floatinginfobox" title="**Contents**"}}
2 {{toc/}}
3 {{/box}}
4
5 = I- Introduction =
6
7 (((
8 The "XMLToExcel" connector allows you to transform an XML file into an Excel file following a given format.
9 The connector uses the Apache POI library to perform the transformation.
10 )))
11
12 (((
13 Here is what you can do very easily (You can do much better by making the view much prettier 😊):
14 )))
15
16 (((
17
18 )))
19
20 [[image:1619519065381-729.png||height="220" width="664"]]
21
22
23 [[image:1619519086074-417.png]]
24
25 [[image:1619519092034-893.png]]
26
27 Let's get to the heart of the matter.
28
29
30 = II- Parameters & Templates =
31
32
33 == Parameters ==
34
35 {{{You will find the "XMLToExcel" connector in the connectors palette:}}}
36
37 [[image:1619519234897-825.png]]
38
39 {{{Here are the parameters of the "XMLToExcel" connector:
40 - Format: The format that specifies all the visual parameters of the document
41 - Template: A Template file can be specified pre-filled with images / shapes… ==> Parameter not required.
42 - File name: The name of the output file.
43 - Input file: The input must take the form's format.}}}
44
45 == [[image:1619519361984-295.png]] ==
46
47
48 == Templates ==
49
50 {{{The connector will be based on a Template if exist, otherwise it will create a new Excel file.
51 The Template parameter is optional.}}}
52
53
54 = III- 1st Example: File with a template containing datas =
55
56 == Template ==
57
58 Below the following Template: An Excel file with two sheets (Preamble and Jobs)
59
60 - Preamble :
61
62 [[image:1619519878302-168.png||height="282" width="709"]]
63
64
65 - Jobs :
66
67
68 [[image:1658745886978-898.png||height="242" width="605"]]
69
70
71 {{{The “Jobs” sheet contains a conditional display in the status and duration column:
72 - Status “OK” will be displayed in green
73 - Status “KO” will be displayed in red
74 - status “Warn” will be displayed in orange
75 - Time greater than 500 seconds will be displayed in red.}}}
76
77 == **/! Important\** ==
78
79 {{{The new version of the XMLToExcel connector forces us to delete cells in the template before inserting data. The new version uses streaming's data and it uses no resources (RAM - CPU...)
80
81 }}}
82
83 == ==
84
85 == Output File ==
86
87 {{{In this example, we want to generate this Excel file : }}}
88
89 [[image:1619521020905-384.png||height="206" width="725"]]
90
91 And a filled data table :
92
93 [[image:1619521047676-484.png||height="314" width="723"]]
94
95 Datas will be inserted into the Excel file taking into account the initial format of the Template (including conditional display)
96
97
98 == File format ==
99
100 The format file used for this transformation :
101
102 {{code language="xml"}}
103
104 <iXDoc>
105 <styleSheet1 styleSheetName="Preamble" actif="true">
106 <Preambule type="table">
107 <Date beginLine="4">
108 <value column="E"></value>
109 </Date>
110 <Description>
111 <value column="E"></value>
112 </Description>
113 </Preambule>
114 </styleSheet1>
115 <styleSheet2 styleSheetName="Jobs" >
116 <Jobs type="table">
117 <Job beginLine="3">
118 <JOBID column="B" formatType="numeric" ></JOBID>
119 <DESCRIPTION></DESCRIPTION>
120 <DURATION formatType="numeric" ></DURATION>
121 <STARTDATE></STARTDATE>
122 <STATUSTYPEID formatType="numeric"></STATUSTYPEID>
123 </Job>
124 </Jobs>
125 </styleSheet2>
126 </iXDoc>
127
128 {{/code}}
129
130
131 == Input File ==
132
133
134 The input file used for this transformation is :
135
136 {{code language="xml"}}
137 <iXDoc>
138 <styleSheet1>
139 <Preambule>
140 <Date>
141 <value>27/04/2021</value>
142 </Date>
143 <Description>
144 <value>Generated dynamically</value>
145 </Description>
146 </Preambule>
147 </styleSheet1>
148 <styleSheet2>
149 <Jobs>
150 <Job>
151 <JOBID>227140</JOBID>
152 <DESCRIPTION>Session 227140 : FTP - R-LIV-076597601-3.XML</DESCRIPTION>
153 <DURATION>164</DURATION>
154 <STARTDATE>2021-01-20 13:13:01.0</STARTDATE>
155 <STATUSTYPEID>0</STATUSTYPEID>
156 </Job>
157 <Job>
158 <JOBID>227141</JOBID>
159 <DESCRIPTION>Received file : /R-LIV-076597601-3.XML' from : 'FML_REPORT</DESCRIPTION>
160 <DURATION>130</DURATION>
161 <STARTDATE>2021-01-20 13:13:01.0</STARTDATE>
162 <STATUSTYPEID>0</STATUSTYPEID>
163 </Job>…
164 </Jobs>…
165
166 {{/code}}
167
168
169 Note that those datas can be retrieved dynamically from a BDDToXML connector for instance.
170
171
172 == Format explanation ==
173
174 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:
175
176
177 (% style="margin-left:auto; margin-right:auto" %)
178 |=Properties|= Description|=Example
179 |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"
180 |actif|Designates whether the page should be active when opening the document or not.
181 This property only exists for "sheet" type tags (which have the "styleSheetName" attribute)|Actif = "true"
182 |type|The type of the sheet element, either "table" or "chart"|(((
183 Type= "table"
184
185 Type= "chart"
186 )))
187 |beginLine|The start line on the chosen sheet|beginLine="4"
188 |column|The start column (in letters)|column= "B"
189 |formatType|The format type of the file's cell|formatType= "numeric"
190
191 = IV- Example 2 : File with a template containing data and graphs =
192
193 == Template ==
194
195 In this part, we want to create a simple Excel file with graphs. Here are the Templates we want to have:
196
197 - "charts" sheet: which contains charts created by the iXPath connector.
198
199 - "datas" sheet: which  contains the appropriate datas.
200
201 [[image:1619522412969-991.png]]
202
203 == OutputFile ==
204
205 The "Charts" sheet:
206
207 [[image:1619522453939-314.png]]
208
209
210 The "Datas" sheet :
211
212 [[image:1619522483742-898.png]]
213
214 == ==
215
216 == File format ==
217
218 {{code language="xml"}}
219 <?xml version="1.0" encoding="UTF-8"?>
220 <iXDoc>
221 <styleSheet1 styleSheetName="datas">
222 <Exemples type="table">
223 <Header beginLine="5">
224 <Date1 column="C" bold="true" color="red" ></Date1>
225 <Date2 column="D" bold="true" color="red" ></Date2>
226 <Date3 column="E" bold="true" color="red" ></Date3>
227 <Date4 column="F" bold="true" color="red" ></Date4>
228 <Date5 column="G" bold="true" color="red" ></Date5>
229 <Date6 column="H" bold="true" color="red" ></Date6>
230 </Header>
231
232 <exemple>
233 <Date1 column="C" formatType="numeric" ></Date1>
234 <Date2 column="D" formatType="numeric" ></Date2>
235 <Date3 column="E" formatType="numeric" ></Date3>
236 <Date4 column="F" formatType="numeric" ></Date4>
237 <Date5 column="G" formatType="numeric" ></Date5>
238 <Date6 column="H" formatType="numeric" ></Date6>
239 </exemple>
240
241 </Exemples>
242 <Exemples2 type="table">
243
244 <Header2 beginLine="5">
245 <Date12 column="J" bold="true" color="red" ></Date12>
246 <Date22 bold="true" color="red" ></Date22>
247 <Date32 bold="true" color="red" ></Date32>
248 </Header2>
249 <exemple2>
250 <Date12 column="J" formatType="numeric" ></Date12>
251 <Date22 formatType="numeric" ></Date22>
252 <Date32 formatType="numeric" ></Date32>
253 </exemple2>
254
255 </Exemples2>
256 </styleSheet1>
257
258 <styleSheet2 styleSheetName="charts" actif="true">
259 <chart1 type="chart" AreaRange="3-17-B-I" sheet="datas" chartType="LINE3D" horizontal="true" bottomAxisTitle="Dates" leftAxisTitle="flows type" legend="Number of flows per day (LINE)" ></chart1>
260
261 <chart2 type="chart" AreaRange="3-17-J-Q" sheet="datas" chartType="BAR3D" horizontal="true" bottomAxisTitle="Dates" stacked="true" leftAxisTitle="flows type" legend="Number of flows per day (BAR)" ></chart2>
262
263 <chart3 type="chart" AreaRange="3-17-R-Y" sheet="datas" chartType="PIE3D" bottomAxisTitle="" leftAxisTitle="" legend="Number of flows per TYPE (SCATTER)" stacked="true" ></chart3>
264
265 </styleSheet2>
266 </iXDoc>
267
268
269 {{/code}}
270
271
272 == Input file ==
273
274 {{code language="xml"}}
275 <?xml version="1.0" encoding="UTF-8"?>
276 <iXDoc>
277 <styleSheet1>
278 <Exemples>
279 <Header>
280 <Date1>10/04/2021</Date1>
281 <Date2>11/04/2021</Date2>
282 <Date3>12/04/2021</Date3>
283 <Date4>13/04/2021</Date4>
284 <Date5>14/04/2021</Date5>
285 <Date6>15/04/2021</Date6>
286 </Header>
287 <exemple>
288 <Date1>1033</Date1>
289 <Date2>1042</Date2>
290 <Date3>900</Date3>
291 <Date4>1313</Date4>
292 <Date5>1502</Date5>
293 <Date6>1432</Date6>
294 </exemple>
295 <exemple>
296 <Date1>801</Date1>
297 <Date2>743</Date2>
298 <Date3>1032</Date3>
299 <Date4>802</Date4>
300 <Date5>998</Date5>
301 <Date6>1203</Date6>
302 </exemple>
303 <exemple>
304 <Date1>1203</Date1>
305 <Date2>902</Date2>
306 <Date3>1320</Date3>
307 <Date4>730</Date4>
308 <Date5>1503</Date5>
309 <Date6>1094</Date6>
310 </exemple>
311 </Exemples>
312
313 <Exemples2>
314 <Header2>
315 <Date12>INVOICE</Date12>
316 <Date22>ORDER</Date22>
317 <Date32>DESADV</Date32>
318 </Header2>
319 <exemple2>
320 <Date12>4670</Date12>
321 <Date22>3780</Date22>
322 <Date32>5490</Date32>
323 </exemple2>
324 </Exemples2>
325
326 </styleSheet1>
327 <styleSheet2>
328 <chart1 keysRange="5-5-C-H" valuesRange="6-6-C-H:7-7-C-H:8-8-C-H" aliasValue="INVOICE:ORDER:DESADV" ></chart1>
329 <chart2 keysRange="5-5-C-H" valuesRange="6-6-C-H:7-7-C-H:8-8-C-H" aliasValue="INVOICE:ORDER:DESADV" ></chart2>
330 <chart3 keysRange="5-5-C-H" valuesRange="6-6-C-H:7-7-C-H:8-8-C-H" aliasValue="INVOICE:ORDER:DESADV" ></chart3>
331 </styleSheet2>
332
333 </iXDoc>
334
335
336
337 {{/code}}
338
339
340 == Format explanation ==
341
342 (% style="margin-left:auto; margin-right:auto" %)
343 |**Properties**|**Description **|**Example**
344 |bold|The "bold" property can be applied to a column of data to make the style of the cell bold|bold= "true"
345 |color|Change a color of a cell|color = "red"
346 |italic|The "italic" property can be applied to a column of data to make the style of the cell in italic|italic= "true"
347 |AreaRange|The range of the graph position.
348 Example: AreaRange = "3-17-J-Q"  Means that the graph must be positioned from the 3rd row to the 17th row, and from column J to column Q|AreaRange="3-17-J-Q"
349 |sheet|The sheet where the chart data is located|Sheet = "Datas"
350 |chartType|
351 The types of the graph, here is the exhaustive list:
352 - PIE
353 - PIE3D
354 - LINE
355 - LINE3D
356 - BAR (Stacked, unstacked, horizontal / vertical)
357 - BAR3D (Stacked, unstacked, horizontal / vertical)
358 - AREA
359 - SCATTER
360 - RADAR|chartType="LINE3D"
361 |horizontal|Applicable for the Bar & BAR3D type graph, this makes the graph horizontal, by default the graph is vertical|horizontal="true"
362 |bottomAxisTitle|The wording of the x-axis|bottomAxisTitle="Dates"
363 |leftAxisTitle|The label of the y-axis|leftAxisTitle="Flows"
364 |legend|The legend of the graph|legend="Number of flows per TYPE (SCATTER)"
365 |Stacked|Application for the BAR & BAR3D type graph, this makes the graph stored on a single column. "False" is the default.|stacked="true"
366
367 == Input File explanation ==
368
369
370 (% style="margin-left:auto; margin-right:auto" %)
371 |**Properties**|**Description **|**Example**
372 |keysRange|The range (The position) of the data keys.Example: keysRange = "5-5-C-H" ==> it Means the data keys are in the 5th row and from column C to column H.|keysRange="5-5-C-H"
373 |valuesRange|The range of data values ​​(Separated by ":" if several types of data exist).|valuesRange="6-6-C-H:7-7-C-H:8-8-C-H"
374 |aliasValue|Label of the traces, the number of labels must be the same as the number of the row of data.|aliasValue="INVOICE:ORDER:DESADV"
375 |hide|Hide a row in the Excel sheet|<exemple Hide="true"/>
376
377
This wiki is hosted and managed by iXPath
Powered by XWiki 13.3 debian