Excel file (.xlsx) is actually a zipped folder of XML files. When some functions (e.g. partial superscript, read only) are not supported by Python packages like openpyxl, we can consider changing the content of an Excel file direcly using Jinja
- Unzip the .xlsx file (or just replace the .xlsx to .zip)
- Copy workbook.xml and all xml files in sheet folder to template folder
- Replace all .xml in template folder to .j2
- Change xml contents using Jinja syntax
- Stream and dump contents to j2 templates (see
example.py
)