---
title: "Excel to PDF/UA | Nutrient Python SDK"
canonical_url: "https://www.nutrient.io/guides/python/templates/spreadsheet-template-to-pdf-ua/"
md_url: "https://www.nutrient.io/guides/python/templates/spreadsheet-template-to-pdf-ua.md"
last_updated: "2026-08-21T00:00:00.000Z"
description: "Generate workbooks from Excel templates with JSON data and convert to accessible PDF/UA format in Nutrient Python SDK."
---

# Generating PDF/UA from Excel templates

This guide explains how to generate an Excel workbook from a template and convert the generated file to PDF/UA with Nutrient Python SDK.

Use this workflow for invoices, financial reports, statements, and other workbooks that use a fixed worksheet design with variable content. PDF/UA helps generated PDFs meet accessibility requirements for assistive technologies such as screen readers.

[Download sample](https://www.nutrient.io/downloads/samples/python/spreadsheet-template-to-pdf-ua.zip)

## Generating a workbook and exporting PDF/UA

Nutrient Python SDK handles the template processing and PDF/UA export workflow. The sample performs the following tasks:

- Open an Excel template.

- Load a JSON data model.

- Apply the data model to replace placeholders.

- Configure PDF/UA conformance.

- Export the generated document as a PDF.

## Complete implementation

The following sections build the complete Python example. First, import the classes required for document processing, template editing, PDF conformance, and error handling:

```python

from nutrient_sdk import Document
from nutrient_sdk import SpreadsheetEditor
from nutrient_sdk import PdfConformance
from nutrient_sdk import NutrientException

```

Open the Excel template file. The [context-manager](https://docs.python.org/3/reference/datamodel.html#context-managers) syntax closes the document when processing finishes:

```python

def main():
    try:
        with Document.open("input_spreadsheet.xlsx") as document:

```

Create a `SpreadsheetEditor` instance for template processing:

```python

            editor = SpreadsheetEditor.edit(document)

```

Read the JSON data model that contains the values for the template placeholders:

```python

            try:
                with open("input_spreadsheet_model.json", "r") as f:
                    model = f.read()
            except IOError:
                print("Failed to read template model file")
                return

```

Apply the template model, save the generated workbook, and close the editor:

```python

            editor.apply_template_model(model)
            editor.save()
            editor.close()

```

Configure PDF/UA conformance and export the document as an accessible PDF:

```python

            # Configure PDF settings for PDF/UA conformance

            pdf_settings = document.settings.pdf_settings
            pdf_settings.conformance = PdfConformance.PDF_UA_1

            document.export_as_pdf("output.pdf")
            print("Successfully generated accessible PDF from template")
    except NutrientException as e:
        print(f"Error: {e}")

if __name__ == "__main__":
    main()

```

## Conclusion

The template processing workflow consists of five steps:

1. Open the Excel template.

2. Create a spreadsheet editor.

3. Apply the JSON template model.

4. Configure PDF/UA conformance.

5. Export the generated workbook as a PDF.

Use this pattern when you have a fixed Excel worksheet design and variable content from a data model.

Download the [sample package](https://www.nutrient.io/downloads/samples/python/spreadsheet-template-to-pdf-ua.zip) to run this example as-is.
---

## Related pages

- [Nutrient Python SDK template guides](/guides/python/templates.md)
- [Generating PDF/UA from PowerPoint templates](/guides/python/templates/presentation-template-to-pdf-ua.md)
- [Word template generation and processing](/guides/python/templates/word-template-generation.md)
- [Word template processing-to-PDF/UA conversion](/guides/python/templates/word-template-to-pdf-ua.md)

