Using Spreadsheets as Data Sources

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
The example reads the shop data described in The Business Layer.

Using Spreadsheets as Data Sources

Following classes are added in GroupDocs.Assembly.Data namespace:

The Recipe

  • Define template and output report documents
  • Assemble a document using the external document table as a data source

Download

Data Source Document

Template

The Code

from groupdocs.assembly import DataSourceInfo, DocumentAssembler
from groupdocs.assembly.data import DocumentTable, DocumentTableOptions

options = DocumentTableOptions()
options.first_row_contains_column_names = True
table = DocumentTable("contracts.xlsx", 0, options)

assembler = DocumentAssembler()
assembler.assemble_document("table-row.docx", "table-row-report.docx", DataSourceInfo(table, "contracts"))

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

The following sample file is used in this example: contracts.xlsx

Binary file (DOCX, 10 KB)

Download full output