Word Activities
Version: 1.0.0 · ID: zoan-packages-word · Author: Zoan Software
The Word package reads and creates .docx documents, without the need to have Microsoft Word installed. Its two main uses:
- Read documents: extract their text, paragraphs and tables for processing.
- Generate documents: create letters, contracts, reports or minutes from data, combining paragraphs with styles, tables and images.
Concept 1: Fast Mode vs. session mode
Section titled “Concept 1: Fast Mode vs. session mode”As in Excel, there are two ways to work:
Quick mode (path)
Section titled “Quick mode (path)”The read and one-time modification activities accept a path directly: they open the file, do the operation, and close it. Ideal for loose operation.
Word Read Text path = = asset("contrato.docx") → output: textoSession mode (session)
Section titled “Session mode (session)”For several operations on the same document—and mandatory to build a new document—you open a session with Word Open (existing document) or Word Create (new document), and share that session with the other activities.
Word Create path = "C:/salida/reporte.docx" └─ body: Word Append Paragraph text = "Reporte mensual" style = Title Word Append Table table = = datosWithin body, activities inherit the session automatically, and when the document is finished it is saved and closed alone (with Create) or closed (with Open).
Concept 2: Paragraph Styles
Section titled “Concept 2: Paragraph Styles”When adding paragraphs with Word Append Paragraph, you can apply a style that gives visual structure to the document:
| Estilo | for what |
|---|---|
Title | The main title of the document |
Heading1 / Heading2 / Heading3 | Section Headings (Levels) |
Normal | Body text (default) |
Activities
Section titled “Activities”Session (open, create, save, close)
Section titled “Session (open, create, save, close)”| Activity | Type | Output | What it does |
|---|---|---|---|
| Word Open | word-open | ZoanWordSession | Open an existing .docx |
| Word Create | word-create | ZoanWordSession | Create a new .docx |
| Word Save | word-save | — | Save the session to disk |
| Word Close | word-close | — | Sign out |
| Activity | Type | Output | What it does |
|---|---|---|---|
| Word Read Text | word-read-text | string | All document text |
| Word Read Paragraphs | word-read-paragraphs | List | Paragraph List |
| Word Read Tables | word-read-tables | List | Tables as DataTables |
Build content (session required)
Section titled “Build content (session required)”| Activity | Type | Output | What it does |
|---|---|---|---|
| Word Append Paragraph | word-append-paragraph | — | Add a paragraph (with style) |
| Word Append Table | word-append-table | — | Add a DataTable as a table |
| Word Insert Image | word-insert-image | — | Insert an image |
Modify and metadata
Section titled “Modify and metadata”| Activity | Type | Output | What it does |
|---|---|---|---|
| Word Find & Replace | word-find-replace | int | Busca y reemplaza texto |
| Word Get Property | word-get-property | object | Read metadata (title, author…) |
| Word Set Property | word-set-property | — | Assign a metadata |
A typical flow
Section titled “A typical flow”Generate a letter from a template with markers:
Copy File source = = asset("plantilla_carta.docx") destination = = "C:/cartas/" + cliente.nit + ".docx" overwrite = trueWord Find & Replace path = = "C:/cartas/" + cliente.nit + ".docx" find = "{NOMBRE}" replace = = cliente.nombreWord Find & Replace path = = "C:/cartas/" + cliente.nit + ".docx" find = "{FECHA}" replace = = today().ToString("yyyy-MM-dd")Next steps
Section titled “Next steps”- Word Create — generate a document from scratch.
- Word Read Text — read a document.
- Word Find & Replace — rellenar plantillas.