Excel Connector
Version 22.0.8473
Version 22.0.8473
Excel Connector
The Excel Connector converts data between Excel sheets (.xlsx
) and XML files.
Overview
Excel Connectors can be configured in two modes: Table and Template. These modes are outlined below.
Table Mode
The default mode for Excel Connectors is Table. This mode only supports converting files from .xlsx
to .xml
. To convert from .xml
to .xslx
, use Template mode.
In Table mode, the connector treats input .xlsx
files exactly like .csv
files. The resulting output .xml
file has the following structure, where each row (record) in the original file becomes a child of the root element Items:
<Items>
<Record>
<field_0></field_0>
<field_1></field_1>
<field_2></field_2>
</Record>
</Items>
Template Mode
In Template mode, the connector uses a template file to perform conversions. This template file matches the output file format:
- When converting from XML to Excel, the Template File is an Excel file.
- When converting from Excel to XML, the Template File is an XML file.
These template files use ArcScript to dynamically populate the output files with data from the input files. For more information, please see the Templates section.
Connector Configuration
This section contains all of the configurable connector properties.
Settings Tab
Configuration
Settings related to the core configuration of the connector.
- Connector Id The static name of the connector. All connector-specific files are held in a folder by the same name within the Data Directory.
- Connector Description An optional field to provide free-form description of the connector and its role in the flow.
- Translation Mode Specifies the method to use (Table or Template) when translating the input file to the output format. See above for more information.
- Column headers present (Table mode) When checked, the translation uses the values in the first row of the
.xlsx
file as the element names of the child elements. If unchecked, the value elements are given generic names such as field_0, field_1, etc. - Template File (Template mode) The file that functions as the output template. Data is dynamically added to the file based on the scripting within the template. More information can be found in the Templates section.
Other Settings
Settings not included in the previous categories.
- Local File Scheme A filemask for determining local file names as they are downloaded by the connector. Hover over the field for a full list of available macros.
Message
Settings that determine how the connector will search for messages and handle them after processing.
- Save to Sent Folder A toggle that instructs the connector to keep a copy of sent messages in the Sent folder.
- Sent Folder Scheme Instructs the connector to group files in the Sent folder according to the selected interval. For example, the Weekly option instructs the connector to create a new subfolder each week and store all sent files for the week in that folder. The blank setting tells the connector to save all files directly in the Sent folder. For connectors that process many transactions, using subfolders can help keep files organized and improve performance.
Logging
Settings that govern the creation and storage of logs.
- Log Level Specifies the type of information to log in the connector’s Logs directory:
- None — Does not create any logs.
- Error — Creates logs only when the connector encounters an error.
- Warning — Creates logs only when the connector issues a warning.
- Info — Logs general information about the workflow, including any errors and warnings (if applicable).
- Debug — Logs detailed debugging information for both successful and failed workflows.
- Trace — Logs detailed trace information for both successful and failed workflows.
Please note that Debug and Trace may log sensitive information including message contents and SSL certificates. Although connection properties (such as passwords) are masked, please review logs of this level for sensitive information before sharing them outside of your organization.
- Log Subfolder Scheme Instructs the connector to group files in the Logs folder according to the selected interval. For example, the Weekly option instructs the connector to create a new subfolder each week and store all logs for the week in that folder. The blank setting tells the connector to save all logs directly in the Logs folder. For connectors that process many transactions, using subfolders can help keep logs organized and improve performance.
- Log Messages A toggle that instructs the connector to save a copy of the most recent message in the Logs directory. Note that the connector only keeps one message per subfolder, and the connector overrides the previously-saved message when it runs again.
Miscellaneous
Settings for specific use cases.
- Other Settings Allows configuration of hidden connector settings in a semicolon-separated list, like
setting1=value1;setting2=value2
. Normal connector use cases and functionality should not require use of these settings.
Automation Tab
Settings related to the automatic processing of files by the connector.
Automation Settings
- Send Whether messages arriving at the connector will automatically be processed.
Performance
Settings related to the allocation of resources to the connector.
- Max Workers The maximum number of worker threads that will be consumed from the threadpool to process files on this connector. If set, overrides the default setting from the Profile tab.
- Max Files The maximum number of files that will be processed by the connector each time worker threads are assigned to the connector. If set, overrides the default setting from the Profile tab.
Templates
XML to Excel
The following snippet from an XML file contains a list of elements under the /Items/Orders
path.
<Items>
<Orders>
<OrderNo>0706</OrderNo>
<Customer>Jerry Seinfeld</Customer>
<TotalCost>100 USD</TotalCost>
<OrderDate>11/02/1995</OrderDate>
<ShipDate>11/05/1995</ShipDate>
<Comments>50 cartons of soup</Comments>
</Orders>
</Items>
To convert this XML file to an Excel file, you must create an Excel template. The image below shows an example Excel template that uses xmlDOMSearch and xpath to loop through the elements of the XML file:
Every Excel template must contain the following elements, which are shown in the example above:
- Static column headers. In the example above, this is Order Details.
- Scripting within Excel comments. This scripting should use the xmlDOMSearch operation to loop through the input XML at a specified XPath. In the example above, this is contained in the arc:call operation.
- Scripting within Excel cells. This scripting should use the xpath formatter to read values from the XML at a given xpath. This xpath is relative to the xpath specified in the xmlDOMSearch operation.
The details of the xmlDOMSearch operation and xpath formatters in this example are described below.
xmlDOMSearch
The xmlDOMSearch requires two parameters:
URI parameter
The URI is the resource path to the XML file to parse. The [filepath] attribute resolves to the input XML file to the connector, and the URI should almost always be set to this value. In the above example, the filepath is URL-encoded with the urlencode formatter to ensure that special characters in the filepath do not prevent the connector from reading the file: [filepath | urlencode]
xpath parameter
The xpath is the XML path to loop over in the document. The operation loops for each occurrence of the specified xpath. For example, with the xpath /Items/Orders, each Orders element that is a child of the root Items element will cause a new set of output in the resulting Excel file.
xpath formatters
The Excel comments with the xmlDOMSearch operation surround a block of cells that reference the input XML via the xpath formatter. The xpath formatter reads values from the input XML at the specified xpath. Note that this xpath is relative to the path provided as a parameter to the xmlDOMSearch operation.
In the above example, the first cell is populated with: [xpath("OrderNo")]. Since this xpath is relative, the cell will be populated with the value from the following path in the input XML: /Items/Orders/OrderNo.
If the xmlDOMSearch operation loops more than once—that is, if more than one instance of the operation’s xpath parameter is found—then the block of cells between the Excel comments will be repeated. The new cells are added vertically, so in the above example the second OrderNo cell would be directly below the first Comments cell.
Excel to XML
To convert from an Excel file to an XML file, you must create a custom XML template using ArcScript commands. Since XML does not support the same scripting functionality as Excel files, the structure and formatting for converting from Excel to XML are different than XML to Excel.
Note: Due to the wide range of potential input and output structures, there is no universal solution for every conversion need. The example template shown below is just one of many potential solutions, and you will need to create a template based on your own needs.
This example template uses a combination of standard XML syntax and ArcScript to read, process, and convert data from an input Excel file.
<!-- Read Excel -->
<arc:set attr="xml.file" value="[FilePath]" />
<arc:set attr="xml.version" value="2007" />
These arc:set
lines specify the location of the file and the Excel version that was used to create the file.
<!-- Always use first sheet-->
<arc:call op="excelListSheets" in ="xml" out="sheet">
<arc:set attr="xml.sheet" value="[sheet.sheet]" />
<arc:break />
</arc:call>
<!-- read the headers into an array-->
<arc:set attr="xml.map:headers" value="A1:*1" />
<arc:call op="excelGet" in="xml" out="header">
<arc:enum attr="header.headers#">
<arc:set attr="data.headernames#" value="[_value | toalphanum | replace(' ','')]" />
</arc:enum>
</arc:call>
<arc:set attr="_log.info" value="[data.headernames#1]" />
<arc:enum range="A..Z">
<arc:set attr="tmp.cells#" value="[_value]" />
</arc:enum>
These sections specify the parameters of conversion and map the headers into standard XML formatting.
The parameter [_value | toalphanum | replace(' ','')]
indicates that the arc:set
command should parse header names from the Excel file, convert them to alphanumeric format, eliminates blank spaces, and assign them as headers in the XML file.
<!-- read the remaining cells -->
<arc:enum attr="data.headernames#">
<arc:set attr="xml.map:[_value]" value="[tmp.cells#[_index]]2:[tmp.cells#[_index]]*" />
</arc:enum>
<!-- build the columns -->
<arc:call op="excelGet" in="xml" out="cols">
<arc:map from="cols" to="data" map="*=*" />
</arc:call>
<Items>
<arc:enum attr="data.[data.headernames#1]#"><arc:set attr="tmp.colIndex" value="[_index]" />
<Record>
<arc:enum attr="data.headernames#">
<[_value]>[data.[_value]#[tmp.colIndex] | def]</[_value]>
</arc:enum>
</Record>
</arc:enum>
</Items>
These sections process the remaining data and build the data columns according to the specified structure.
Excel Operations
In addition to the Operations provided with Arc, connectors may provide operations that extend functionality into ArcScript. Operations specific to the functionality of the Excel Connector are listed below.
excelClose
Close an Excel connection.
Optional Parameters
- handle: The handle for the Excel file.
Output Attributes
- success: True if the connection is closed successfully.
excelCreate
Create a new Excel worksheet.
Required Parameters
- sheet: The name of the Excel worksheet to create inside the workbook. The default value is ‘sheet1’.
Optional Parameters
- file: The path to the Excel workbook.
- version: The version of Excel you are using. The allowed values are ‘AUTO, 95, 97-2003, 2007’. The default value is ‘AUTO’.
- overwrite: Indicates whether to overwrite the file if it already exists. The allowed values are ‘true, false’. The default value is ‘false’.
- columnnames: Comma-separated list of the column names of the new spreadsheet. Column names cannot contain white space.
Output Attributes
- file: The name of the Excel workbook updated.
- sheet: The name of the Excel worksheet to be created inside the workbook. May be different from the sheet specified if the name conflicts with one already existing.
excelDelete
Delete the row by RowId in an Excel worksheet.
Required Parameters
- sheet: The name of the Excel worksheet.
- RowId: The start row index to be deleted from the document. Starts from 1.
- count: The count of rows to be deleted from the document.
Optional Parameters
- version: The version of Excel you are using. The allowed values are ‘AUTO, 95, 97-2003, 2007’. The default value is ‘AUTO’.
- file: The path to the Excel workbook.
- handle: The handle for the Excel file.
- headerlocation: Location of the column headers. The default value is ‘NONE’.
- recalculate: If true, the cell formulas that depend on the changed cells will be recalculated. If not, they will be calculated on the first opening in Excel. The default value is ‘true’.
- Ignorecalcerror: If IgnoreCalcError is set to True any errors that occur due to formula calculation will be ignored. If this happens the formula result may be unreliable but other data will be accurate. The default value is ‘false’.
- logfile: The log file used to log any errors that occurred during the calculation.
- CloseFile: Indicates whether to close the file now or wait until the connection is closed.
Output Attributes
- file: The name of the Excel workbook updated.
- sheet: The name of the Excel worksheet updated.
excelGet
Queries the specified Excel worksheet.
Required Parameters
- sheet: The name of the Excel worksheet.
Optional Parameters
- version: The version of Excel you are using. The allowed values are ‘AUTO, 95, 97-2003, 2007’. The default value is ‘AUTO’.
- file: The path to the Excel workbook.
- handle: The handle for the Excel file.
- map:*: This set of inputs contains a mapping of the attribute name and the name of the cell whose value is to be retrieved from the spreadsheet. For example, the attribute name map:MyValue which has a value of C1 will push an attribute named MyValue with the value found in the cell at C1 in the sheet. A range of cell names can also be specified to retrieve a range of cell values.
Output Attributes
- *: Dependent on the content of the sheet and the query specified. If column headers are present they will be used to name the output attributes.
excelGetHeader
Describe the specified Excel worksheet.
Required Parameters
- sheet: The name of the Excel worksheet.
Optional Parameters
- version: The version of Excel you are using. The allowed values are ‘AUTO, 95, 97-2003, 2007’. The default value is ‘AUTO’.
- file: The path to the Excel workbook.
- handle: The handle for the Excel file.
- headerlocation: Location of the column headers. The default value is ‘NONE’.
- headernames: Comma-delimited list of column or row headers that you want to use (for example, firstName, lastName).
- recalculate: If true, recalculate the formulas and save the results before returning values. The default value is ‘true’.
- Ignorecalcerror: If ignorecalcerror is set to True any errors that occur due to formula calculation will be ignored. If this happens the formula result may be unreliable but other data will be accurate. The default value is ‘false’.
- logfile: The log file used to log any errors that occurred during the calculation.
- typedetectionscheme: The scheme to detect the data type.
- rowScandepth: The row scan depth.
Output Attributes
- *: Dependent on the content of the sheet and the range specified.
- meta:row: The index of the row in the Excel document.
excelInsert
Append a record to an Excel sheet.
Required Parameters
- sheet: The name of the Excel worksheet.
- cell#: The cells you want to update.
- value#: The values you want to set to the range.
Optional Parameters
- version: The version of Excel you are using. The allowed values are ‘AUTO, 95, 97-2003, 2007’. The default value is ‘AUTO’.
- file: The path to the Excel workbook.
- handle: The handle for the Excel file.
- headerlocation: Location of the column headers. The default value is ‘NONE’.
- RowId: The index of the row appended to the document.
- dataType#: The data types you want to set to the range.
- allowformula: If true, the cell value that starts with an equals sign (=) will be treated as a formula. The default value is ‘true’.
- recalculate: If true, the cell formulas that depend on the changed cells will be recalculated. If not, they will be calculated on the first opening in Excel. The default value is ‘true’.
- ignorecalcerror: If IgnoreCalcError is set to True any errors that occur due to formula calculation will be ignored. If this happens the formula result may be unreliable but other data will be accurate. The default value is ‘false’.
- logfile: The log file used to log any errors that occurred during the calculation.
- CloseFile: Indicates whether to close the file now or wait until the connection is closed.
Output Attributes
- sheet: The name of the Excel worksheet updated.
- RowId: The index of the row appended to the document.
excelListSheets
Lists the worksheets in a specified Excel workbook.
Optional Parameters
- version: The version of Excel you are using. The allowed values are ‘AUTO, 95, 97-2003, 2007’. The default value is ‘AUTO’.
- file: The path to the Excel workbook.
- handle: The handle for the Excel file.
Output Attributes
- isHidden: Returns true if the sheet is hidden from view in Excel.
- sheet: The name of the Excel worksheet. Note that the name ends with $. This is not required when specifying worksheet names to other operations.
excelOpen
Open an existing Excel workbook.
Required Parameters
- file: The path to the Excel workbook.
Optional Parameters
- version: The version of Excel you are using. The allowed values are ‘AUTO, 95, 97-2003, 2007’. The default value is ‘AUTO’.
Output Attributes
- handle: The handle which is used to execute other ops.
excelUpdate
Update cells in an Excel worksheet.
Required Parameters
- sheet: The name of the Excel worksheet.
- RowId: The index of the row updated to the document.
- cell#: The cells you want to update.
- value#: The values you want to set to the range.
Optional Parameters
- version: The version of Excel you are using. The allowed values are ‘AUTO, 95, 97-2003, 2007’. The default value is ‘AUTO’.
- file: The path to the Excel workbook.
- handle: The handle for the Excel file.
- headerlocation: Location of the column headers. The default value is ‘NONE’.
- allowformula: If true, the cell value that starts with the equals sign (=) will be treated as formula. The default value is ‘true’.
- recalculate: If true, the cell formulas that depend on the changed cells will be recalculated. If not, they will be calculated on the first opening in Excel. The default value is ‘true’.
- Ignorecalcerror: If IgnoreCalcError is set to True any errors that occur due to formula calculation will be ignored. If this happens the formula result may be unreliable but other data will be accurate. The default value is ‘false’.
- logfile: The log file used to log any errors that occurred during the calculation.
- CloseFile: Indicates whether to close the file now or wait until the connection is closed.
Output Attributes
- file: The name of the Excel workbook updated.
- sheet: The name of the Excel worksheet updated.
- range: The cell range updated.