Excel Activities
Version: 1.0.0 · ID: zoan-packages-excel · Author: Zoan Software
The Excel package reads and writes .xlsx files without having to have Microsoft Excel installed. It is one of the most used packages in automation: almost every office process goes through a spreadsheet — reading a list, filling out a template, consolidating data, generating a report.
Concept 1: Fast Mode vs. session mode
Section titled “Concept 1: Fast Mode vs. session mode”Almost all activities accept one of two parameters to indicate which file to work on: path or session.
Quick mode (path)
Section titled “Quick mode (path)”You pass the file path directly to the activity. This opens, performs the operation, saves and closes automatically. Ideal for loose operation.
Read Excel Sheet path = = asset("clientes.xlsx") → output: tablaSession mode (session) — for various operations
Section titled “Session mode (session) — for various operations”If you are going to do several operations on the same file, opening and closing it each time is slow. Instead, you open it once with Excel Open, get a session (ZoanExcelSession), and pass it to the other activities with session. In the end you close it with Excel Close (which saves).
Excel Open path = = asset("reporte.xlsx") → output: libroWrite Excel Sheet session = = libro sheet = "Datos" data = = tablaWrite Excel Cell session = = libro sheet = "Resumen" cell = "B2" value = = totalExcel Close session = = libroConcept 2: sheet, range or cell
Section titled “Concept 2: sheet, range or cell”You can read and write with three granularities, depending on what you need:
| Nivel | Read | Escribir | Formato de datos |
|---|---|---|---|
| Sheet | Read Excel Sheet | Write Excel Sheet | DataTable (with headers) — the most convenient |
| Rango | Read Excel Range | Write Excel Range | List of lists (raw values) |
| Cell | Read Excel Cell | Write Excel Cell | A loose value |
Cell and sheet notation
Section titled “Cell and sheet notation”- Cells: A1 notation —
A1,B3,AA10. - Ranges:
A1:D50(from the top left cell to the bottom right). - Sheets: by name (
"Datos") or by 1-based index (1= first sheet). By default, the first sheet.
Activities
Section titled “Activities”Session (open, save, close)
Section titled “Session (open, save, close)”| Activity | Type | Output | What it does |
|---|---|---|---|
| Excel Open | excel-open | ZoanExcelSession | Open a workbook and return a session |
| Excel Save | excel-save | — | Save the session to disk (or another path) |
| Excel Close | excel-close | — | Save and log out |
| Activity | Type | Output | What it does |
|---|---|---|---|
| Read Excel Sheet | excel-read-sheet | DataTable | Read a sheet to a DataTable |
| Read Excel Range | excel-read-range | List | Read a range as raw values |
| Read Excel Cell | excel-read-cell | object | Read a cell |
| Get Sheet Names | excel-get-sheet-names | List | Names of all sheets |
| Get Used Range | excel-get-used-range | Dictionary | Dimensions of the data area |
| Find Excel Cell | excel-find-cell | Dictionary | Find the first cell with a value |
| Activity | Type | Output | What it does |
|---|---|---|---|
| Write Excel Sheet | excel-write-sheet | — | Write a DataTable to a sheet |
| Write Excel Range | excel-write-range | — | Write values from a cell |
| Write Excel Cell | excel-write-cell | — | Write a value in a cell |
| Append Excel Range | excel-append-range | — | Add rows below existing data |
| Append Excel Rows | excel-append-rows | — | Add rows from a DataTable to the end (header only if empty) |
| Clear Excel Range | excel-clear-range | — | Clears the contents of a range or sheet |
A typical flow
Section titled “A typical flow”Read a list, process it and write a report:
Read Excel Sheet path = = asset("pedidos.xlsx") sheet = "Pedidos" → output: pedidos
For Each items = = pedidos itemVariable = fila └─ activities: ... procesar cada pedido ...
Write Excel Sheet path = = "C:/salida/reporte.xlsx" sheet = "Resultado" data = = pedidosNext steps
Section titled “Next steps”- Excel Open — start working with a file in session mode.
- Read Excel Sheet — the most common reading.
- Data types › DataTable — work with the read data.