Skip to content

Word Read Tables

Type: word-read-tables  ·  Package: Word Activities v1.0.4  ·  Output: List<DataTable>

Reads all the tables of a Word document and returns them as a list of DataTables (one per table in the document). Useful to extract tabular data from documents: a price list, a listing, an appendix.

Finds the document’s tables, in order, and turns each one into a DataTable. It accepts session or path — see the two modes; with path it opens the file, reads it and closes it without changes.

  • With hasHeader = true (default): the first row gives the column names (trimmed of leading and trailing spaces) and the rest are data rows.
  • With hasHeader = false: columns are named Col1, Col2… and every row is data.
  • The number of columns is set by the first row. If a row has fewer cells (for example, because of merged cells), the missing ones stay empty; if it has more, the extra ones are ignored.
  • All cells are read as text.
  • Tables nested inside another table are also returned, as separate items in the list.
  • hasHeader is set in the editor; it does not accept expressions.

None — but you must provide session or path.

ParameterTypeDefaultDescription
sessionZoanWordSession—Session from Word Open (instead of path). Inherited automatically inside a body.
pathstring—Path to the .docx (quick mode). Only used when there is no session.
hasHeaderbooltrueThe first row of each table holds the headers.

Returns a List of DataTable, one per table in document order. If the document has no tables, the list is empty. Get one table with tables[0] or first(tables).

Process the first table of the document:

Word Read Tables path = asset("appendix.docx") → output: tables
If condition = count(tables) > 0
└─ then:
Set Variable name = firstTable value = first(tables)
Log message = "Rows: " + rowCount(firstTable)
MessageCause and fix
'session' or 'path' is required.There is no session and no path.
File not found.The path does not exist on the robot’s machine.
Duplicate column name errorWith hasHeader = true, two cells in the first row have the same text. Use hasHeader = false and rename the columns afterwards with DataTable.