Microsoft Excel Writer
The adapter converts an XML document with a specified table structure into a Microsoft Excel file (in .xls
format Excel 97 – 2003 or XML-based OOXML format .xlsx
)or fills an existing Excel file (in.xls
format Excel 97 – 2003 or XML-based OOXML format .xlsx
) with data from an XML document with a specified table structure.
Properties
Operation | Determines which operation the adapter executes Possible values:
|
Parameter
Adapter | Main class of the adapter (do not change!) Possible values: en.softproject.integration.adapter.excel.ExcelWriter: Main class (default) |
generateOOXML | Determine Excel file format (Microsoft Excel 97 - 2003 or OOXML) Possible values:
|
TemplateUrl | URL to the Excel template (if the Operation property is set to Possible values:
|
recalc | Recalculate formulas and update field values before saving the document Possible values:
|
Status values
1 | The operation was executed successfully. |
-1 | The operation failed due to a technical error. |
Input
Depending on the selected operation, the adapter expects a specific input structure:
Operation Create Spreadsheet
For this operation, the adapter expects the following XML structure, which corresponds to the structure of (X)HTML tables. Here, the <table>
element creates a table sheet, each <tr>
element creates a new table row and each <td>
element creates a new cell or <th>
a header cell. If several table sheets are to be created, the <table>
elements must be enclosed by a root element with any name.
The table name which is specified using the name
attribute in the <table>
element is restricted to 31 characters.
Example input for the Create Spreadsheet operation
<?xml version="1.0" encoding="UTF-8"?>
<root>
<table name="Name of the first spreadsheet">
<tr autofit="true" height="10">
<th fontHeight="12" forceString="true" autofit="true" bold="true">Header1</th>
<th fontHeight="12" forceString="true" autofit="true" bold="true">Header2</th>
</tr>
<tr>
<td>Value1</td>
<td>Value11</td>
</tr>
<tr>
<td>Value2</td>
<td>Value22</td>
</tr>
<tr>
<td>Value3</td>
<td>Value33</td>
</tr>
</table>
</root>
With the attribute forceString="true"
, the content is not interpreted as a number or date, but written directly into the Excel document.
Example: 008.07300
is written into the Excel document as the number 8.073
without the attribute forceString="true"
, with the attribute forceString="true"
it is written into the Excel document as the string 008.07300
.
Operation Fill Template
For this operation, the adapter expects the following XML structure. In the optional attribute templateUrl="... "
you can specify a valid URL to a template file, e.g. templateUrl="file:///C:/Template.xlsx"
. This specification overwrites the value of the adapter parameter TemplateURL
. Each <cell>
element corresponds to a cell of the table. For row and, if applicable, column numbers, the count starts at 0.
Example input for operation FillTemplate
<TemplateFill templateUrl="URL to template file">
<cell sheet = "Name of the spreadsheet"
row = "Row number"
col = "Column ID "
value = "Cell content"
formatNumber = "Format number"
wrapText="true"/>
</TemplateFill>
Possible attributes
The formatting of the individual cells can be controlled via the following attributes:
Attribut | Description | ||||
---|---|---|---|---|---|
formatNumber | Number format Possible values:
| ||||
fontName | Font, e.g. Calibri | ||||
horizontalAlignment | Horizontal alignment of the text within the cell Possible values:
| ||||
verticalAlignment | Vertical alignment of the text within the cell Possible values:
| ||||
fontHeight | Font Size | ||||
fontColor | Font color Possible values:
| ||||
bold | Bold font Possible values:
| ||||
italic | Italic font Possible values:
| ||||
underline | Type of underline Possible values:
| ||||
cellColor | Fill colour of the cell Possible values:
| ||||
border | Type of cell frame Possible values:
| ||||
borderColor | Cell frame colour Possible values:
| ||||
orientation | Text alignment Possible values:
| ||||
wrapText | Optional attribute: Allow automatic line break in cells Possible values:
| ||||
autofit | Optional attribute: Automatically adjust column width Possible values:
Set the attribute Please note:
| ||||
width | Optional attribute: Define fixed column width
If the
autofit attribute is set, the width attribute is ignored.
Possible values: Number between Set the attribute Please note:
| ||||
height | Optional attribute: Define row height Excel applies the automatic adjustment of the height with the Possible values: number between Set the attribute Please note:
|