In-Table List With Alternate Content in HTML 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 In-Table Master-Detail report in HTML Document format.

In-Table List With Alternate Content in HTML Document

Reporting Requirement

As a report developer, you are required to represent your products and their prices with the following key requirements:

  • Report must show each product along with its price.
  • It must show sum of all the prices.
  • It must represent all the information in tabular form.
  • Report must be generated in the HTML Document.

Adding Syntax to be evaluated by GroupDocs.Assembly Engine

Products

Order Price

<<if [!Any()]>>No data

<<else>><<foreach [in orders]>><<[Product.ProductName]>>

<<[Price]>><</foreach>>

Total:

<<[Sum(c => c.Price)]>><</if>>

Tip
For detailed technical information about syntax, expressions and report generation by the engine, please visit: Working with GroupDocs.Assembly Engine

Download In-Table List With Alternate Content Template

Please download the sample In-Table list with alternate content 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("orders.json", encoding="utf-8") as f:
    orders = json.load(f)

assembler = DocumentAssembler()
assembler.assemble_document("in-table-list-with-alternate-content.html", "in-table-list-with-alternate-content-report.html", DataSourceInfo(orders, "orders"))

The following sample file is used in this example: in-table-list-with-alternate-content.html

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

<html>
<body>
<table>
Regular text. <span style="background-color:orange">Highlighted text.</span>
<th>
Customer
</th>
<th>
Order Price
</th>
[TRUNCATED]

Download full output