Skip to main content

Libreoffice files generator programmatically with python and Libreoffice server instances

Project description

UnoGenerator PyPI - Downloads Github - Downloads Tests

Description

UnoGenerator is a powerful Python module designed to generate LibreOffice documents (ODT and ODS) programmatically with high performance and professional aesthetics.

Key features include:

  • Professional Defaults: Automatic text wrapping (word_wrap=True) and vertical centering for professional-looking reports out of the box.
  • High Performance: Optimized for large datasets. Inserting 10,000 rows with default formatting takes less than 0.3 seconds.
  • Rich Exports: Easy export to .xlsx, .docx, and .pdf.
  • Advanced Helpers: Flexible totals generation, automatic column width calculation, and complex data block handling.
  • Multilingual Support: Built-in support for translations and localized document generation.

It uses the LibreOffice UNO module, requiring a LibreOffice installation on your system.

Installation

Only Linux is supported. See the installation guide for detailed instructions on main Linux distributions.

Architecture

UnoGenerator follows a clean, template-based architecture:

  • ODS/ODT: Generic base classes for document manipulation.
  • ODS_Standard / ODT_Standard: Optimized subclasses that use the built-in professional templates, providing specific styles (like "Normal", "BoldCenter") and optimized row heights.

ODT 'Hello World' example

Create a professional ODT document with just a few lines:

from unogenerator import ODT_Standard

with ODT_Standard() as doc:
    doc.addParagraph("Hello World", "Heading 1")
    doc.addParagraph("Easy, isn't it", "Standard")
    doc.save("hello_world.odt")
    doc.export_docx("hello_world.docx")
    doc.export_pdf("hello_world.pdf")

ODS 'Hello World' example

Generate a styled spreadsheet with automatic wrapping and alignment:

from unogenerator import ODS_Standard

with ODS_Standard() as doc:
    # word_wrap and vertical alignment are enabled by default
    doc.addCellMergedWithStyle("A1:E1", "Sales Report 2026", style="BoldCenter")
    doc.addRowWithStyle("A2", ["Product", "Quantity", "Price", "Total"])
    doc.save("sales_report.ods")
    doc.export_xlsx("sales_report.xlsx")

Advanced Features: Totals and Formulas

UnoGenerator provides advanced helpers to generate calculations quickly:

from unogenerator import helpers

# Generates both row and column totals with a custom formula template
helpers.cross_totals_from_range(doc, "B2:D10", key="=SUM({}*1.21)")

Unogenerator scripts

The package includes several useful CLI tools:

unogenerator_monitor

Monitors your LibreOffice server instances and their status.

unogenerator_translation

Translate multiple ODT files using standard .pot and .po files. unogenerator_translation --from_language es --to_language en --input original.odt --output_directory "translated"

unogenerator_demo

Generate comprehensive example files and perform performance benchmarks on your system.

Documentation

Full technical documentation is available in the doc directory, created using UnoGenerator itself.

Development links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

unogenerator-1.3.0.tar.gz (843.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

unogenerator-1.3.0-py3-none-any.whl (860.2 kB view details)

Uploaded Python 3

File details

Details for the file unogenerator-1.3.0.tar.gz.

File metadata

  • Download URL: unogenerator-1.3.0.tar.gz
  • Upload date:
  • Size: 843.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.13.13 Linux/7.0.8-gentoo

File hashes

Hashes for unogenerator-1.3.0.tar.gz
Algorithm Hash digest
SHA256 0e4faae057de06faefb974fa45043e570cb5993ef4bfd48118e384aa302568d4
MD5 bd7d71794fcec25b496ae8fa1620670d
BLAKE2b-256 ef3de0fed25db53e407ff3e66ee12a46a4d25675fb31e3209505438ad2ce397a

See more details on using hashes here.

File details

Details for the file unogenerator-1.3.0-py3-none-any.whl.

File metadata

  • Download URL: unogenerator-1.3.0-py3-none-any.whl
  • Upload date:
  • Size: 860.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.13.13 Linux/7.0.8-gentoo

File hashes

Hashes for unogenerator-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 01da27be4276eab3bd291e9265caa62b0752f47c159bc0334d47a71c6300f539
MD5 6971ffa1096ce70587422e4e7d794c81
BLAKE2b-256 acb55432f24c48681d5d7c3f26e1d7922e47e47496449778daa132c4360d9d6e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page