Skip to main content

odsgenerator, a .ods generator.

Generate an OpenDocument Format .ods file from a .json or .yaml file.

When used as a script, odsgenerator parses a JSON or YAML description of tables and generates an ODF document using the odfdo library.

When used as a library, odsgenerator parses a Python description of tables and returns the ODF content as bytes (ready to be saved as a valid ODF document).

  • The content description can be minimalist: a list of lists of lists,
  • or description can be complex, allowing styles at row or cell level.

See also https://github.com/jdum/odsparsator which is doing the reverse operation, .osd to .json.

odsgenerator is a Python package, using the odfdo library. Current version requires Python >= 3.10, see prior versions for older environments.

Project: https://github.com/jdum/odsgenerator

Author: jerome.dumonteil@gmail.com

License: MIT

Installation

Installation from Pypi (recommended):

pip install odsgenerator

Installation from sources:

uv sync

CLI usage

odsgenerator [-h] [--version] input_file output_file

arguments

input_file: input file containing data in JSON or YAML format

output_file: output file, .ods file generated from the input

Use odsgenerator --help for more details about input file parameters and look at examples in the tests folder.

Usage from python code

from odsgenerator import odsgenerator

content = odsgenerator.ods_bytes([[["a", "b", "c"], [10, 20, 30]]])
with open("sample.ods", "wb") as file:
    file.write(content)

The resulting .ods file loaded in a spreadsheet:

spreadsheet screnshot

Another example with more parameters:

import odsgenerator

content = odsgenerator.ods_bytes(
    [
        {
            "name": "first tab",
            "style": "cell_decimal2",
            "table": [
                {
                    "row": ["a", "b", "c"],
                    "style": "bold_center_bg_gray_grid_06pt",
                },
                [10, 20, 30],
            ],
        }
    ]
)
with open("sample2.ods", "wb") as file:
    file.write(content)

The .ods file loaded in a spreadsheet, with gray background on first line:

spreadsheet screnshot

Principle

  • A document is a list or dict containing tabs,
  • a tab is a list or dict containing rows,
  • a row is a list or dict containing cells.

Documentation

See in the `./doc folder:

  • html/odsgenerator.html
  • tutorial.json or tutorial.yml and tutorial.ods

License

This project is licensed under the MIT License (see the LICENSE file for details).

Download files

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

Source Distribution

odsgenerator-1.15.0.tar.gz (9.6 kB view details)

Uploaded Source

Built Distribution

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

odsgenerator-1.15.0-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

Details for the file odsgenerator-1.15.0.tar.gz.

File metadata

  • Download URL: odsgenerator-1.15.0.tar.gz
  • Upload date:
  • Size: 9.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for odsgenerator-1.15.0.tar.gz
Algorithm Hash digest
SHA256 83f82bec25f4dadfc0f2e0624409d3bf59a856688f8292f5ee9614a823541d41
MD5 a90bec16acf3d31af95d5c47e6d7a466
BLAKE2b-256 c8d2797a3e3d3e5ea2a0ac57bda53f54e19a8e64f7d88962fcd567ee1a1ebafd

See more details on using hashes here.

File details

Details for the file odsgenerator-1.15.0-py3-none-any.whl.

File metadata

  • Download URL: odsgenerator-1.15.0-py3-none-any.whl
  • Upload date:
  • Size: 10.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for odsgenerator-1.15.0-py3-none-any.whl
Algorithm Hash digest
SHA256 da7bca0c858eb0da9b43ffbd53f8cba1b2949ae7987a22f4783d7a079e8a0ae1
MD5 343a364380ab6977f840f4af14f9ae48
BLAKE2b-256 5923058a4c54598d57611cdd08ec802b6d6e4cf875a6fee353edbbaf3167b35d

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 Sentry Error logging StatusPage Status page