1. GroupDocs Documentation
  2. /
  3. GroupDocs.Assembly Product Family
  4. /
  5. GroupDocs.Assembly for Python
  6. /
  7. Developer Guide
  8. /
  9. Advanced Usage
  10. /
  11. Defining Relations Between DocumentTable Instances Loaded from a Single Document

Defining Relations Between DocumentTable Instances Loaded from a Single Document

View as MarkdownMarkdown

Set up your AI agent

Give your coding agent live access to the GroupDocs documentation and API reference through the GroupDocs Docs MCP server — no install, no API key. Learn more

claude mcp add --transport http groupdocs-docs https://docs.groupdocs.com/mcp

Also process documents locally

The GroupDocs.Assembly MCP server lets your agent work with files on your machine; they are never uploaded. It needs the .NET 10 SDK or Docker.

claude mcp add groupdocs-assembly -- dnx GroupDocs.Assembly.Mcp --yes
Folders, licensing and more →

Define Relations Between Document Table Instances

API provides ability to define relations between DocumentTable instances loaded from a single document. The following classes of the GroupDocs.Assembly.Data namespace have been added:

Moreover, the Relations property of the GroupDocs.Assembly.Data.DocumentTableSet class has been added.

Data Source Document

Template

Using Document Table Relations

Note
The example reads the shop data described in The Business Layer.
from groupdocs.assembly import DataSourceInfo, DocumentAssembler
from groupdocs.assembly.data import DocumentTableOptions, DocumentTableSet

def load_table(args):
    # The first row of every table holds its column names
    options = DocumentTableOptions()
    options.first_row_contains_column_names = True
    args.options = options

tables = DocumentTableSet("related-tables.xlsx", load_table)
tables.relations.add(tables.tables["CLIENT"].columns["ID"], tables.tables["CONTRACT"].columns["CLIENT_ID"])
tables.relations.add(tables.tables["MANAGER"].columns["ID"], tables.tables["CONTRACT"].columns["MANAGER_ID"])

assembler = DocumentAssembler()
assembler.assemble_document("table-relations.docx", "table-relations-report.docx", DataSourceInfo(tables))

The following sample file is used in this example: table-relations.docx

The following sample file is used in this example: related-tables.xlsx

Binary file (DOCX, 10 KB)

Download full output