Skip to content
Snippets Groups Projects

ENH: xlsx template generator

Merged Henrik tom Wörden requested to merge f-xlsx-json into f-more-jsonschema-export
2 unresolved threads
@@ -65,4 +65,25 @@ def fill_template(template_path: str, json_path: str, result_path: str) -> None:
``template_path`` and store the result under ``result_path``.
"""
template = load_workbook(template_path)
# For each top level key in the json we iterate the values (if it is an array). Those are the
# root elements that belong to a particular sheet.
# After treating a root element, the row index for the corresponding sheet needs to be
# increased
# When we finished treating an object that goes into a lower ranked sheet (see below), we
# increase the row index of that sheet.
#
# We can generate a hierarchy of sheets in the beginning (using the paths). The lower sheets
# are for objects referenced by objects in higher ranked sheets.
# We can detect the sheet corresponding to a root element by looking at the first path element:
# The first path element must be the root element every where.
# Suggestion:
# row indices: Dict[str, int] string is the sheet name
# sheet_hirarchy: List[Tuple[str]] elements are sheet names
#
# Question:
# We can create an internal representation where we assign as sheet_names the same names that
# are used in table generator. Or should we create another special row that contains this
# somehow?
template.save(result_path)
Loading