Common Master-Detail in Text 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 →
Note
In this article, we will use GroupDocs.Assembly to generate a Common Master-Detail report in Text Document format.

Common Master-Detail in Text Document

Reporting Requirement

As a report developer, you are required to represent the information of the customers and products with the following key requirements:

  • It must associate the customers with their products
  • Report must be generated in the HTML Document

Adding Syntax to be evaluated by GroupDocs.Assembly Engine

<<foreach [in customers]>><<[CustomerName()]>>
Products: <<foreach [in Order]>><<[indexOf() != 0 ? ", " : ""]>><<[Product.ProductName]>><</foreach>>
<</foreach>>
Tip
For detailed technical information about syntax, expressions and report generation by the engine, please visit: Working with GroupDocs.Assembly Engine.

Download Common Master-Detail Template

Please download the sample Common master-detail document we created in this article:

Generating The Report

Note
The example reads the shop data described in The Business Layer.
import json

from groupdocs.assembly import DataSourceInfo, DocumentAssembler

with open("customers.json", encoding="utf-8") as f:
    customers = json.load(f)

assembler = DocumentAssembler()
assembler.assemble_document("common-master-detail.txt", "common-master-detail-report.txt", DataSourceInfo(customers, "customers"))

The following sample file is used in this example: common-master-detail.txt

The following sample file is used in this example: customers.json

Quayside Bistro
Products: Harbor Blend whole bean coffee, Aged harbour cheddar, Cold-pressed olive oil

Lantern Street Café
Products: Lighthouse Espresso beans, Oat and honey biscuits

Saltmarsh Deli
Products: Chestnut honey, Smoked gouda, Autumn Harvest apple butter

Pier Nine Kitchen
[TRUNCATED]

Download full output