Skip to main content

xlsx_from_json

Creates xlsx from json via openpyxl.

Usage

Create .json file with following structure:

{
    "rows": [
        {
            "cells": [
                {
                    "value": "Sample text",
                    // merge 5x2 cell range
                    "width": 5,
                    "height": 2,
                    // openpyxl style: https://openpyxl.readthedocs.io/en/2.5/styles.html
                    "style": {
                        "font": {
                            "name": "Times New Roman",
                            "size": 12
                        },
                        "border": {
                          "bottom": {
                            // openpyxl border styles: // https://openpyxl.readthedocs.io/en/stable/_modules/openpyxl/styles/borders.html
                            "border_style": "medium",
                            "color": "FFFFFFFF"
                          }
                        }
                    }
                }
            ],
            // move row by 2x1
            "skip_columns": 2,
            "skip_rows": 1,
            // change row height
            "row_height": 10
        }
    ],
    "start_column": 1,
    "start_row": 1,
    // change column widths
    "column_widths": [
        {
            // column_number or column_letter
            "column_number": 1,
            "width": 10
        }
    ],
    // set number format (e.g. 1.234 -> 1.23)
    "number_format": "0.00",
    // apply style to all cells
    "default_style": {
        "font": {
            "bold": true
        }
    }
}

Create openpyxl workbook via xlsx_from_json function:

import json
from xlsx_from_json import xlsx_from_json

with open("data.json", encoding="utf-8") as f:
    json_data = json.load(f)

wb = xlsx_from_json(json_data)

Created workbook will have values:

sheet = wb.active
assert sheet.cell(row=2, cell=3).value == "Sample text"

The same true for the styles (cell ctyle + default style):

sheet = wb.active
assert sheet.cell(row=2, cell=3).font.name == "Times New Roman"
assert sheet.cell(row=2, cell=3).font.bold == True

Now you can use workbook according to openpyxl guide.

Metadata

Release files for xlsx-from-json 1.0.1

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

Source distribution (sdist)

Source distribution for xlsx-from-json 1.0.1
File Size Uploaded Provenance Actions
xlsx_from_json-1.0.1.tar.gz 5.1 kB Without provenance Details for xlsx_from_json-1.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for xlsx-from-json 1.0.1
File Interpreter ABI Platform Actions
xlsx_from_json-1.0.1-py3-none-any.whl Python 3 none any Details for xlsx_from_json-1.0.1-py3-none-any.whl

Total release size: 11.7 kB

Release files / xlsx_from_json-1.0.1.tar.gz

Download URL xlsx_from_json-1.0.1.tar.gz
Size 5.1 kB
Tags Source
SHA-256 checksum
How to use checksums
3ff087e8e775ce0c5058661c303c59939346485ae49268f495129bbea0d07216
BLAKE2b-256 checksum
How to use checksums
09067d4e9ce23bc37c9bae48c751e44c80d42eecca2e415f1afbeee83d959ef4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.6.5

Release files / xlsx_from_json-1.0.1-py3-none-any.whl

Download URL xlsx_from_json-1.0.1-py3-none-any.whl
Size 6.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e389cd487b82d75698400a266057358de4f66b0aea5ac28cc62e5493e7f771f5
BLAKE2b-256 checksum
How to use checksums
2d3cf483e314f00719da73923abbac3570f2cf80e36dfe895d8dc2b926b79e60
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.6.5

Security for xlsx-from-json 1.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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