Wiki source code of XMLToExcel
Version 22.1 by Achraf El Kari on 2022/07/25 12:49
Show last authors
author | version | line-number | content |
---|---|---|---|
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 use no resources (RAM - CPU...) | ||
80 | |||
81 | }}} | ||
82 | |||
83 | (% class="wikigeneratedid" %) | ||
84 | == == | ||
85 | |||
86 | == Output File == | ||
87 | |||
88 | {{{In this example, we want to generate this Excel file : }}} | ||
89 | |||
90 | [[image:1619521020905-384.png||height="206" width="725"]] | ||
91 | |||
92 | And a filled data table : | ||
93 | |||
94 | [[image:1619521047676-484.png||height="314" width="723"]] | ||
95 | |||
96 | Datas will be inserted into the Excel file taking into account the initial format of the Template (including conditional display) | ||
97 | |||
98 | |||
99 | == File format == | ||
100 | |||
101 | The format file used for this transformation : | ||
102 | |||
103 | {{code language="xml"}} | ||
104 | |||
105 | <iXDoc> | ||
106 | <styleSheet1 styleSheetName="Preamble" actif="true"> | ||
107 | <Preambule type="table"> | ||
108 | <Date beginLine="4"> | ||
109 | <value column="E"></value> | ||
110 | </Date> | ||
111 | <Description> | ||
112 | <value column="E"></value> | ||
113 | </Description> | ||
114 | </Preambule> | ||
115 | </styleSheet1> | ||
116 | <styleSheet2 styleSheetName="Jobs" > | ||
117 | <Jobs type="table"> | ||
118 | <Job beginLine="3"> | ||
119 | <JOBID column="B" formatType="numeric" ></JOBID> | ||
120 | <DESCRIPTION></DESCRIPTION> | ||
121 | <DURATION formatType="numeric" ></DURATION> | ||
122 | <STARTDATE></STARTDATE> | ||
123 | <STATUSTYPEID formatType="numeric"></STATUSTYPEID> | ||
124 | </Job> | ||
125 | </Jobs> | ||
126 | </styleSheet2> | ||
127 | </iXDoc> | ||
128 | |||
129 | {{/code}} | ||
130 | |||
131 | |||
132 | == Input File == | ||
133 | |||
134 | |||
135 | The input file used for this transformation is : | ||
136 | |||
137 | {{code language="xml"}} | ||
138 | <iXDoc> | ||
139 | <styleSheet1> | ||
140 | <Preambule> | ||
141 | <Date> | ||
142 | <value>27/04/2021</value> | ||
143 | </Date> | ||
144 | <Description> | ||
145 | <value>Generated dynamically</value> | ||
146 | </Description> | ||
147 | </Preambule> | ||
148 | </styleSheet1> | ||
149 | <styleSheet2> | ||
150 | <Jobs> | ||
151 | <Job> | ||
152 | <JOBID>227140</JOBID> | ||
153 | <DESCRIPTION>Session 227140 : FTP - R-LIV-076597601-3.XML</DESCRIPTION> | ||
154 | <DURATION>164</DURATION> | ||
155 | <STARTDATE>2021-01-20 13:13:01.0</STARTDATE> | ||
156 | <STATUSTYPEID>0</STATUSTYPEID> | ||
157 | </Job> | ||
158 | <Job> | ||
159 | <JOBID>227141</JOBID> | ||
160 | <DESCRIPTION>Received file : /R-LIV-076597601-3.XML' from : 'FML_REPORT</DESCRIPTION> | ||
161 | <DURATION>130</DURATION> | ||
162 | <STARTDATE>2021-01-20 13:13:01.0</STARTDATE> | ||
163 | <STATUSTYPEID>0</STATUSTYPEID> | ||
164 | </Job>… | ||
165 | </Jobs>… | ||
166 | |||
167 | {{/code}} | ||
168 | |||
169 | |||
170 | Note that those datas can be retrieved dynamically from a BDDToXML connector for instance. | ||
171 | |||
172 | |||
173 | == Format explanation == | ||
174 | |||
175 | 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: | ||
176 | |||
177 | |||
178 | (% style="margin-left:auto; margin-right:auto" %) | ||
179 | |=Properties|= Description|=Example | ||
180 | |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" | ||
181 | |actif|Designates whether the page should be active when opening the document or not. | ||
182 | This property only exists for "sheet" type tags (which have the "styleSheetName" attribute)|Actif = "true" | ||
183 | |type|The type of the sheet element, either "table" or "chart"|((( | ||
184 | Type= "table" | ||
185 | |||
186 | Type= "chart" | ||
187 | ))) | ||
188 | |beginLine|The start line on the chosen sheet|beginLine="4" | ||
189 | |column|The start column (in letters)|column= "B" | ||
190 | |formatType|The format type of the file's cell|formatType= "numeric" | ||
191 | |||
192 | = IV- Example 2 : File with a template containing data and graphs = | ||
193 | |||
194 | == Template == | ||
195 | |||
196 | In this part, we want to create a simple Excel file with graphs. Here are the Templates we want to have: | ||
197 | |||
198 | - "charts" sheet: which contains charts created by the iXPath connector. | ||
199 | |||
200 | - "datas" sheet: which contains the appropriate datas. | ||
201 | |||
202 | [[image:1619522412969-991.png]] | ||
203 | |||
204 | == OutputFile == | ||
205 | |||
206 | The "Charts" sheet: | ||
207 | |||
208 | [[image:1619522453939-314.png]] | ||
209 | |||
210 | |||
211 | The "Datas" sheet : | ||
212 | |||
213 | [[image:1619522483742-898.png]] | ||
214 | |||
215 | == == | ||
216 | |||
217 | == File format == | ||
218 | |||
219 | {{code language="xml"}} | ||
220 | <?xml version="1.0" encoding="UTF-8"?> | ||
221 | <iXDoc> | ||
222 | <styleSheet1 styleSheetName="datas"> | ||
223 | <Exemples type="table"> | ||
224 | <Header beginLine="5"> | ||
225 | <Date1 column="C" bold="true" color="red" ></Date1> | ||
226 | <Date2 column="D" bold="true" color="red" ></Date2> | ||
227 | <Date3 column="E" bold="true" color="red" ></Date3> | ||
228 | <Date4 column="F" bold="true" color="red" ></Date4> | ||
229 | <Date5 column="G" bold="true" color="red" ></Date5> | ||
230 | <Date6 column="H" bold="true" color="red" ></Date6> | ||
231 | </Header> | ||
232 | |||
233 | <exemple> | ||
234 | <Date1 column="C" formatType="numeric" ></Date1> | ||
235 | <Date2 column="D" formatType="numeric" ></Date2> | ||
236 | <Date3 column="E" formatType="numeric" ></Date3> | ||
237 | <Date4 column="F" formatType="numeric" ></Date4> | ||
238 | <Date5 column="G" formatType="numeric" ></Date5> | ||
239 | <Date6 column="H" formatType="numeric" ></Date6> | ||
240 | </exemple> | ||
241 | |||
242 | </Exemples> | ||
243 | <Exemples2 type="table"> | ||
244 | |||
245 | <Header2 beginLine="5"> | ||
246 | <Date12 column="J" bold="true" color="red" ></Date12> | ||
247 | <Date22 bold="true" color="red" ></Date22> | ||
248 | <Date32 bold="true" color="red" ></Date32> | ||
249 | </Header2> | ||
250 | <exemple2> | ||
251 | <Date12 column="J" formatType="numeric" ></Date12> | ||
252 | <Date22 formatType="numeric" ></Date22> | ||
253 | <Date32 formatType="numeric" ></Date32> | ||
254 | </exemple2> | ||
255 | |||
256 | </Exemples2> | ||
257 | </styleSheet1> | ||
258 | |||
259 | <styleSheet2 styleSheetName="charts" actif="true"> | ||
260 | <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> | ||
261 | |||
262 | <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> | ||
263 | |||
264 | <chart3 type="chart" AreaRange="3-17-R-Y" sheet="datas" chartType="PIE3D" bottomAxisTitle="" leftAxisTitle="" legend="Number of flows per TYPE (SCATTER)" stacked="true" ></chart3> | ||
265 | |||
266 | </styleSheet2> | ||
267 | </iXDoc> | ||
268 | |||
269 | |||
270 | {{/code}} | ||
271 | |||
272 | |||
273 | == Input file == | ||
274 | |||
275 | {{code language="xml"}} | ||
276 | <?xml version="1.0" encoding="UTF-8"?> | ||
277 | <iXDoc> | ||
278 | <styleSheet1> | ||
279 | <Exemples> | ||
280 | <Header> | ||
281 | <Date1>10/04/2021</Date1> | ||
282 | <Date2>11/04/2021</Date2> | ||
283 | <Date3>12/04/2021</Date3> | ||
284 | <Date4>13/04/2021</Date4> | ||
285 | <Date5>14/04/2021</Date5> | ||
286 | <Date6>15/04/2021</Date6> | ||
287 | </Header> | ||
288 | <exemple> | ||
289 | <Date1>1033</Date1> | ||
290 | <Date2>1042</Date2> | ||
291 | <Date3>900</Date3> | ||
292 | <Date4>1313</Date4> | ||
293 | <Date5>1502</Date5> | ||
294 | <Date6>1432</Date6> | ||
295 | </exemple> | ||
296 | <exemple> | ||
297 | <Date1>801</Date1> | ||
298 | <Date2>743</Date2> | ||
299 | <Date3>1032</Date3> | ||
300 | <Date4>802</Date4> | ||
301 | <Date5>998</Date5> | ||
302 | <Date6>1203</Date6> | ||
303 | </exemple> | ||
304 | <exemple> | ||
305 | <Date1>1203</Date1> | ||
306 | <Date2>902</Date2> | ||
307 | <Date3>1320</Date3> | ||
308 | <Date4>730</Date4> | ||
309 | <Date5>1503</Date5> | ||
310 | <Date6>1094</Date6> | ||
311 | </exemple> | ||
312 | </Exemples> | ||
313 | |||
314 | <Exemples2> | ||
315 | <Header2> | ||
316 | <Date12>INVOICE</Date12> | ||
317 | <Date22>ORDER</Date22> | ||
318 | <Date32>DESADV</Date32> | ||
319 | </Header2> | ||
320 | <exemple2> | ||
321 | <Date12>4670</Date12> | ||
322 | <Date22>3780</Date22> | ||
323 | <Date32>5490</Date32> | ||
324 | </exemple2> | ||
325 | </Exemples2> | ||
326 | |||
327 | </styleSheet1> | ||
328 | <styleSheet2> | ||
329 | <chart1 keysRange="5-5-C-H" valuesRange="6-6-C-H:7-7-C-H:8-8-C-H" aliasValue="INVOICE:ORDER:DESADV" ></chart1> | ||
330 | <chart2 keysRange="5-5-C-H" valuesRange="6-6-C-H:7-7-C-H:8-8-C-H" aliasValue="INVOICE:ORDER:DESADV" ></chart2> | ||
331 | <chart3 keysRange="5-5-C-H" valuesRange="6-6-C-H:7-7-C-H:8-8-C-H" aliasValue="INVOICE:ORDER:DESADV" ></chart3> | ||
332 | </styleSheet2> | ||
333 | |||
334 | </iXDoc> | ||
335 | |||
336 | |||
337 | |||
338 | {{/code}} | ||
339 | |||
340 | |||
341 | == Format explanation == | ||
342 | |||
343 | (% style="margin-left:auto; margin-right:auto" %) | ||
344 | |**Properties**|**Description **|**Example** | ||
345 | |bold|The "bold" property can be applied to a column of data to make the style of the cell bold|bold= "true" | ||
346 | |color|Change a color of a cell|color = "red" | ||
347 | |italic|The "italic" property can be applied to a column of data to make the style of the cell in italic|italic= "true" | ||
348 | |AreaRange|The range of the graph position. | ||
349 | 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" | ||
350 | |sheet|The sheet where the chart data is located|Sheet = "Datas" | ||
351 | |chartType| | ||
352 | The types of the graph, here is the exhaustive list: | ||
353 | - PIE | ||
354 | - PIE3D | ||
355 | - LINE | ||
356 | - LINE3D | ||
357 | - BAR (Stacked, unstacked, horizontal / vertical) | ||
358 | - BAR3D (Stacked, unstacked, horizontal / vertical) | ||
359 | - AREA | ||
360 | - SCATTER | ||
361 | - RADAR|chartType="LINE3D" | ||
362 | |horizontal|Applicable for the Bar & BAR3D type graph, this makes the graph horizontal, by default the graph is vertical|horizontal="true" | ||
363 | |bottomAxisTitle|The wording of the x-axis|bottomAxisTitle="Dates" | ||
364 | |leftAxisTitle|The label of the y-axis|leftAxisTitle="Flows" | ||
365 | |legend|The legend of the graph|legend="Number of flows per TYPE (SCATTER)" | ||
366 | |Stacked|Application for the BAR & BAR3D type graph, this makes the graph stored on a single column. "False" is the default.|stacked="true" | ||
367 | |||
368 | == Input File explanation == | ||
369 | |||
370 | |||
371 | (% style="margin-left:auto; margin-right:auto" %) | ||
372 | |**Properties**|**Description **|**Example** | ||
373 | |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" | ||
374 | |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" | ||
375 | |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" | ||
376 | |hide|Hide a row in the Excel sheet|<exemple Hide="true"/> | ||
377 | |||
378 |