Skip to content

Cells with field values/drop down menu in word is not recognised as text with _Cells.text #1489

Open

Description

@Heikasee

For cells with a field code or a drop down menu, the library does not recognise the text within them.

For example, here is a word table with the first row having dropdown menus, second row having field values and third row just having normal text

Image

Running through the code below

from docx import Document
import pandas as pd

doc = Document("C:\Developer\example\exampletable.docx")
tables = []
for table in doc.tables:
    # initialise df
    df = [['' for _ in range(len(table.columns))] for _ in range(len(table.rows))]
    
    # populate the df with data from table
    for i, row in enumerate(table.rows):
        for j, cell in enumerate(row.cells):
            df[i][j] = cell.text
    
    tables.append(pd.DataFrame(df))
    
print(tables[0])

results in this table

             0       1
0     Dropdown
1  Field value
2  Normal Text  Hello

Here is the files for the above example: example.zip

Activity

  1. added
    sdtStructured Document Tags (forms)
    on May 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    sdtStructured Document Tags (forms)text

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions