https://github.com/potykion/xlsx_from_json
Creates xlsx from json via openpyxl.
https://github.com/potykion/xlsx_from_json
json openpyxl xlsx
Last synced: about 2 months ago
JSON representation
Creates xlsx from json via openpyxl.
- Host: GitHub
- URL: https://github.com/potykion/xlsx_from_json
- Owner: potykion
- License: mit
- Created: 2018-07-26T20:43:55.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2022-12-08T02:22:43.000Z (over 3 years ago)
- Last Synced: 2025-11-28T23:45:12.976Z (7 months ago)
- Topics: json, openpyxl, xlsx
- Language: Python
- Homepage: https://pypi.org/project/xlsx-from-json/
- Size: 74.2 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# xlsx_from_json
Creates xlsx from json via [openpyxl](https://openpyxl.readthedocs.io/en/latest/index.html).
## Usage
Let's create following table:

Firstly, define .json representation of table:
```java
{
// rows to render
"rows": [
{
"cells": [
{
"value": "Firstname",
"style": {"font": {"bold": true}}
},
{
"value": "Lastname",
"style": {"font": {"bold": true}}
}
]
},
{
"cells": [
{"value": "Jill"},
{"value": "Smith"}
]
},
{
"cells": [
{"value": "Eve"},
{"value": "Jackson"}
]
}
],
// style applied to all cells
"default_style": {
"font": {"name": "Times New Roman", "size": 14}
}
}
```
Then create openpyxl workbook via ``xlsx_from_json`` function:
```python
import json
from xlsx_from_json import xlsx_from_json
with open("example.json", encoding="utf-8") as f:
json_data = json.load(f)
wb = xlsx_from_json(json_data)
```
Created workbook will have cells with defined values and styles:
```python
sheet = wb.active
assert sheet.cell(row=1, cell=1).value == "Firstname"
assert sheet.cell(row=1, cell=1).font.bold == True
assert sheet.cell(row=1, cell=1).font.name == "Times New Roman"
```
Now you can use workbook according to openpyxl [guide](https://openpyxl.readthedocs.io/en/latest/usage.html).