blob: d75ae26d9f5f5df31a31b5df54d8082fa1276b97 [file] [log] [blame]
<!DOCTYPE html>
<head>
<title>RCPTT Documentation Center</title>
<meta charset="UTF-8">
<link rel="stylesheet" href="https://www.eclipse.org/rcptt/shared/css/bootstrap.min.css">
<link rel="stylesheet" href="https://www.eclipse.org/rcptt/shared/css/main.css">
<link rel="stylesheet" href="https://www.eclipse.org/rcptt/shared/css/prism.css">
<link rel="icon" href="https://www.eclipse.org/rcptt/shared/img/favicon.ico">
<script src="https://www.eclipse.org/rcptt/shared/js/jquery.min.js"></script>
<script src="https://www.eclipse.org/rcptt/shared/js/bootstrap.min.js"></script>
<script src="https://www.eclipse.org/rcptt/shared/js/prism.js"></script>
<script src="https://www.eclipse.org/rcptt/shared/js/ecl.js"></script>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-39589807-5', 'eclipse.org');
ga('send', 'pageview');
</script>
</head>
<body>
<div id="before-footer">
<header>
<nav class="navbar navbar-default navbar-static-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<span class="navbar-brand">RCPTT Documentation Center</span>
</div>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li class="active" >
<a href="https://www.eclipse.org/rcptt/documentation/userguide/getstarted">User Guide</a>
</li>
<li >
<a href="https://www.eclipse.org/rcptt/documentation/faq/">FAQ</a>
</li>
<li>
<a href="http://eclipse.org/rcptt">Back to RCPTT Main Site</a>
</li>
<li>
<a href="http://eclipse.org">Eclipse.org</a>
</li>
</ul>
</div>
</nav>
</header>
<section class="content">
<div class="container">
<div class="row">
<div class="col-sm-3">
<div class="rcptt-sidebar">
<ul class="nav">
<li ><a href="https://www.eclipse.org/rcptt/documentation/userguide/getstarted/">Get Started</a>
</li>
<li ><a href="https://www.eclipse.org/rcptt/documentation/userguide/testeditor/">Test Case Editor</a>
</li>
<li ><a href="https://www.eclipse.org/rcptt/documentation/userguide/controlpanel">Control Panel</a>
</li>
<li ><a href="https://www.eclipse.org/rcptt/documentation/userguide/assertions/">Assertions</a>
</li>
<li ><a href="https://www.eclipse.org/rcptt/documentation/userguide/ecl/">Eclipse Command Language</a>
<ul class="nav">
<li >
<a href="https://www.eclipse.org/rcptt/documentation/userguide/ecl/new-command-guide/">New ECL Command Guide</a>
</li>
<li >
<a href="https://www.eclipse.org/rcptt/documentation/userguide/ecl/excel-import-export/">ECL commands for Excel import and export</a>
</li>
</ul>
</li>
<li ><a href="https://www.eclipse.org/rcptt/documentation/userguide/contexts/">Contexts</a>
<ul class="nav">
<li >
<a href="https://www.eclipse.org/rcptt/documentation/userguide/contexts/workspace/">Workspace</a>
</li>
<li >
<a href="https://www.eclipse.org/rcptt/documentation/userguide/contexts/workbench/">Workbench</a>
</li>
<li >
<a href="https://www.eclipse.org/rcptt/documentation/userguide/contexts/launch/">Launch</a>
</li>
<li >
<a href="https://www.eclipse.org/rcptt/documentation/userguide/contexts/preferences/">Preferences</a>
</li>
<li >
<a href="https://www.eclipse.org/rcptt/documentation/userguide/contexts/parameters/">Parameters</a>
</li>
<li >
<a href="https://www.eclipse.org/rcptt/documentation/userguide/contexts/group/">Group</a>
</li>
<li >
<a href="https://www.eclipse.org/rcptt/documentation/userguide/contexts/folder/">Folder</a>
</li>
<li >
<a href="https://www.eclipse.org/rcptt/documentation/userguide/contexts/default/">Default</a>
</li>
<li >
<a href="https://www.eclipse.org/rcptt/documentation/userguide/contexts/super/">Super</a>
</li>
<li >
<a href="https://www.eclipse.org/rcptt/documentation/userguide/contexts/ecl/">ECL Script</a>
</li>
</ul>
</li>
<li ><a href="https://www.eclipse.org/rcptt/documentation/userguide/verifications/">Verifications</a>
<ul class="nav">
<li >
<a href="https://www.eclipse.org/rcptt/documentation/userguide/verifications/text/">Text</a>
</li>
<li >
<a href="https://www.eclipse.org/rcptt/documentation/userguide/verifications/treetable/">Table/Tree</a>
</li>
<li >
<a href="https://www.eclipse.org/rcptt/documentation/userguide/verifications/errorlog/">Error Log</a>
</li>
<li >
<a href="https://www.eclipse.org/rcptt/documentation/userguide/verifications/time/">Time</a>
</li>
</ul>
</li>
<li ><a href="https://www.eclipse.org/rcptt/documentation/userguide/procedures/">Procedures and Variables</a>
</li>
<li ><a href="https://www.eclipse.org/rcptt/documentation/userguide/runner/">Test Runner</a>
<ul class="nav">
<li >
<a href="https://www.eclipse.org/rcptt/documentation/userguide/runner/arguments/">Arguments</a>
</li>
</ul>
</li>
<li ><a href="https://www.eclipse.org/rcptt/documentation/userguide/maven/">Maven plugin</a>
</li>
<li ><a href="https://www.eclipse.org/rcptt/documentation/userguide/rap/">RAP</a>
<ul class="nav">
<li >
<a href="https://www.eclipse.org/rcptt/documentation/userguide/rap/install/">Install instructions</a>
</li>
<li >
<a href="https://www.eclipse.org/rcptt/documentation/userguide/rap/recordReplay/">Record and Replay</a>
</li>
<li >
<a href="https://www.eclipse.org/rcptt/documentation/userguide/rap/capability/">Capability Contexts</a>
</li>
<li >
<a href="https://www.eclipse.org/rcptt/documentation/userguide/rap/rap-commands/">ECL commands</a>
</li>
<li >
<a href="https://www.eclipse.org/rcptt/documentation/userguide/rap/rap-maven/">Maven plugin</a>
</li>
</ul>
</li>
</ul>
</div>
</div>
<div class="col-sm-9">
<h1>ECL commands for Excel import and export</h1>
<br>
<h2>Excel export</h2><hr>
<h3>write-excel-file</h3>
Writes tables from input pipe to into excel (xls or xlsx) file. Fails if file is not found or format is invalid.
Input:
<ul>
<li><b>tables</b> (1, ∞) Table: Tables to write</li>
</ul>
Parameters:
<ul>
<li><b>uri</b> String: URI to write Excel data to. Currently supported schemes are workspace:/ for files in workspace and file:/ for files on local file system.</li>
<li><b>append</b> boolean: Whether to append given table data into file. Default value is false.</li>
</ul>
Output:
<ul>
<li>The value of 'tables' argument</li>
</ul>
Example:
<pre ><code class="language-ecl">&#x200b;proc newDevice [val name] [val target] {
map [entry "Device Name" $name] [entry "Device Target" $target]
}
global [val supportedDevices [list
[newDevice "device 1" "target 1"]
[newDevice "device 2" "target 2"]
[newDevice "device 3" "target 3"]
]]
global [val allDevices [list
[newDevice "device 1" "target 1"]
[newDevice "device 2" "target 2"]
[newDevice "device 3" "target 3"]
[newDevice "device 4" "target 4"]
[newDevice "device 5" "target 5"]
]]
proc newTable [val table] [val name] {
$table | list-as-table-data | set-page-name $name
}
emit [newTable $supportedDevices "Supported devices"] [newTable $allDevices "All devices"]
| write-excel-file "workspace:/excel/devices.xls"
newTable $supportedDevices "Supported devices"
| write-excel-file "workspace:/excel/devices.xls" -append
</code></pre>
<br>
<h2>Excel import</h2><hr>
<h3>read-excel-file</h3>
Parses given excel file (xls or xlsx) into tables and write them to output pipe. Fails if file is not found or format is invalid.
Parameters:
<ul>
<li><b>uri</b> String: URI to read Excel data from. Currently supported schemes are workspace:/ for files in workspace and file:/ for files on local file system.</li>
<li><b>sheets</b> (0, ∞) String: List of Excel sheet names to read data from</li>
</ul>
Output:
<ul>
<li>List of Table EMF Objects</li>
</ul>
Example:
<pre ><code class="language-ecl">&#x200b;proc logInfoItem [val row] [val columns] {
$columns | each [val column] {
log [format "%s: %s" $column [$row | get $column]]
}
}
global [val devicesInfo [
read-excel-file "workspace:/excel/devices.xls" "Supported devices" "All devices"
| to-list
]]
clear-log-view
$devicesInfo | each [val table] {
log [format "Page name: %s" [$table | get-page-name]]
let [val columns [$table | get-column-names]] {
$table | get-rows-data | each [val item] {
// $item | get "Device Name" | log
logInfoItem $item $columns
}
}
}
</code></pre>
<br>
<h2>Additional commands</h2><hr>
<h3>get-page-name</h3>
Get page name from table.
Input:
<ul>
<li><b>table</b> Table: Table to get page name from
</li>
</ul>
Output:
<ul>
<li>Table page name
</li>
</ul>
Example:
<pre ><code class="language-ecl">&#x200b;get-view "Error Log" | get-tree | expand-all
get-view "Error Log" | get-tree | get-table-data
| set-page-name "Table" | write-excel-file "workspace:/MyProject/AssertData/table.xls"
read-excel-file "workspace:/MyProject/AssertData/table.xls"
| get-page-name | equals "Table" | assert-true
</code></pre>
<br>
<h3>set-page-name</h3>
Set page name to table
Input:
<ul>
<li><b>table</b> Table: Table to set page name to</li>
</ul>
Parameters:
<ul>
<li>name String: Page name to set</li>
</ul>
Output:
The value of 'table' argument
Example:
<pre ><code class="language-ecl">&#x200b;get-view "Error Log" | get-tree | expand-all
get-view "Error Log" | get-tree | get-table-data
| set-page-name "Table" | write-excel-file "workspace:/MyProject/AssertData/table.xls"
read-excel-file "workspace:/MyProject/AssertData/table.xls"
| get-page-name | equals "Table" | assert-true
</code></pre>
<br>
<h3>get-column-names</h3>
Get list of column names from table
Input:
<ul><li>
<b>table</b> Table: Table to get column names from</li>
</ul>
Output:
<ul><li>
List of table column names</li>
</ul>
Example:
<pre ><code class="language-ecl">&#x200b;proc logInfoItem [val row] [val columns] {
$columns | each [val column] {
log [format "%s: %s" $column [$row | get $column]]
}
}
get-view "Error Log" | get-tree | expand-all
get-view "Error Log" | get-tree | get-table-data
| write-excel-file "workspace:/MyProject/AssertData/table.xls"
read-excel-file "workspace:/MyProject/AssertData/table.xls"
| to-list | each [val table] {
let [val columns [$table | get-column-names]] {
$table | get-rows-data | each [val item] {
logInfoItem $item $columns
}
}
}
</code></pre>
<br>
<h3>get-rows-data</h3>
Converts table data to map, where column name is a key and cell is a value
Input:
<ul>
<li><b>table</b> Table: Table to get rows data from</li>
</ul>
Output:
<ul>
<li>Map with row values</li>
</ul>
Example:
<pre ><code class="language-ecl">&#x200b;get-view "Error Log" | get-tree | expand-all
get-view "Error Log" | get-tree | get-table-data | write-excel-file
"workspace:/MyProject/AssertData/table.xls"
 
read-excel-file "workspace:/MyProject/AssertData/table.xls"
 | get-rows-data | each [val item] {
  $item | get "Message" | log
}
</code></pre>
<br>
<h3>list-as-table-data</h3>
Converts input list of map to table data format
Input:
<ul><li>
<b>list</b> EclList: List of Map to convert to Table
</li>
</ul>
Output:
<ul>
<li>Table EMF Object</li>
</ul>
Example:
<pre ><code class="language-ecl">&#x200b;proc newDevice [val name] [val target] {
map [entry "Device Name" $name] [entry "Device Info" $target]
}
proc newTable [val table] [val name] {
$table | list-as-table-data | set-page-name $name
}
global [val devices [list
[newDevice "Device 1" "Info 1"]
[newDevice "Device 2" "Info 2"]
[newDevice "Device 3" "Info 3"]
]]
newTable $devices "Devices"
| write-excel-file "workspace:/MyProject/AssertData/devices.xls"
</code></pre>
</div>
</div>
</div>
</section>
<script src="https://www.eclipse.org/rcptt/shared/js/main.js"></script>
</body>