Skip to main content

Creates xlsx from json via openpyxl.

Project description


Creates xlsx from json via openpyxl.


Create .json file with following structure:

    "rows": [
            "cells": [
                    "value": "Sample text",
                    // merge 5x2 cell range
                    "width": 5,
                    "height": 2,
                    // openpyxl style:
                    "style": {
                        "font": {
                            "name": "Times New Roman",
                            "size": 12
                        "border": {
                          "bottom": {
                            // openpyxl border styles: //
                            "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 =
assert sheet.cell(row=2, cell=3).value == "Sample text"

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

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

Now you can use workbook according to openpyxl guide.

Project details

Download files

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

Files for xlsx-from-json, version 1.0.1
Filename, size File type Python version Upload date Hashes
Filename, size xlsx_from_json-1.0.1-py3-none-any.whl (6.5 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size xlsx_from_json-1.0.1.tar.gz (5.1 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page