Win Extract Table
Win Extract Table
Section titled “Win Extract Table”Type: win-extract-table · Package: Desktop Activities v1.0.8 · Output: DataTable
Extracts the data of a table or grid in a desktop application (.NET DataGrid, Java JTable, ListView…) and turns it into a DataTable. It is far more efficient than reading cell by cell: one activity brings you the whole table, ready to process or dump into Excel.
How it works
Section titled “How it works”It locates the grid by its selector and reads its rows and columns, without clicking or scrolling it:
- Rows: every row (UI Automation
DataItemorListItem) inside the grid, up tomaxRows. - Cells: the texts of each row’s controls, in order. If a row has no separate cells, its whole text becomes a single column.
- Columns: with
includeHeader = true, their names are the headers the grid exposes; without headers (or withincludeHeader = false) they are namedcol0,col1,col2…, based on the number of cells in the first row. - In Java applications (JTable) the table is read through the Swing bridge, with its headers.
Every value arrives as text, exactly as shown in the grid. Rows with fewer cells than columns are filled with "".
Required parameters
Section titled “Required parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
selector | selector | — | The table or grid. |
Optional parameters
Section titled “Optional parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
session | ZoanDesktopSession | — | Win Attach session. Inside a body it is taken automatically; without a session, the selector must include the window. |
includeHeader | bool | true | Use the grid’s headers as column names. With false, columns are named col0, col1… |
maxRows | int | 500 | Maximum number of rows to extract. |
timeout | number | 30000 | Maximum ms to wait for the grid. Empty = the project’s UI timeout or, if not set, 30000. |
Output
Section titled “Output”Returns a DataTable: one row per grid row and one text column per column. If the grid is empty, it returns a table with no rows (not an error).
Common errors
Section titled “Common errors”| Message | Cause and fix |
|---|---|
Element not found with selector {…}. | The grid did not appear within timeout. See common errors. |
The Java control could not be located unambiguously, so nothing was done. … | In a Java app there are several identical tables. Add an anchor or an idx to the selector. |
| Duplicate column error | Two grid headers have the same text and can’t both be column names. Use includeHeader = false and rename the columns afterwards. |
Example
Section titled “Example”Win Extract Table selector = (grid "Transactions") → output: transactionsLog message = "Rows extracted: " + rowCount(transactions)
For Each items = transactions itemVariable = row └─ activities: Log message = str(row["Date"]) + " — " + str(row["Amount"])Related activities
Section titled “Related activities”- Win Get Text — read a single cell.
- DataTable — filter, sort and summarize the extracted table.