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).

Release files for odsgenerator 1.16.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for odsgenerator 1.16.0
File Size Uploaded
odsgenerator-1.16.0.tar.gz 9.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for odsgenerator 1.16.0
File Interpreter ABI Platform
odsgenerator-1.16.0-py3-none-any.whl Python 3 none any Details

Total release size: 20.3 kB

Release files / odsgenerator-1.16.0.tar.gz

Download URL odsgenerator-1.16.0.tar.gz
Size 9.7 kB
Tags Source
SHA-256 checksum
How to use checksums
a5445c1f3d10500058eb4004943e96e9d51949fb2267880e1cf00b4d128e1910
BLAKE2b-256 checksum
How to use checksums
b519f8cc48f578cc70d29c28bc25516a7e2bb3ab7e535e2504465ba470550a81
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.9

Release files / odsgenerator-1.16.0-py3-none-any.whl

Download URL odsgenerator-1.16.0-py3-none-any.whl
Size 10.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fc8f35b2e38dcb7319322501fc6cbbbd99104d9d72f9950f687918db71c20cd4
BLAKE2b-256 checksum
How to use checksums
3189c22606f6fd10ab56da8f5edcb109a1e78c869bdb4a2d2bdfd2e1f69f8648
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.9

Release history Release notifications | RSS feed

This release

1.16.0 This release

2 release files

1.12.0

2 release files

1.11.4

2 release files

1.11.3

2 release files

1.11.2

2 release files

1.11.1

2 release files

1.11.0

2 release files

1.9.0

2 release files

1.8.0

2 release files

1.5.0

2 release files

1.4.8

3 release files

1.4.7

3 release files

1.4.5

2 release files

1.4.3

2 release files

1.4.2

3 release files

1.4.0

3 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page