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

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

Close
Loading

Analyzing your prompt, please hold on...

An error occurred while retrieving the results. Please refresh the page and try again.