From 9152953716bb0a702cba5e7d4b5767de4fcda395 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20tom=20W=C3=B6rden?= <h.tomwoerden@indiscale.com> Date: Tue, 5 Mar 2024 08:17:06 +0100 Subject: [PATCH] DOC: added considerations for fill --- .../table_json_conversion/fill_xlsx.py | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/caosadvancedtools/table_json_conversion/fill_xlsx.py b/src/caosadvancedtools/table_json_conversion/fill_xlsx.py index 380a9d62..79c7bfea 100644 --- a/src/caosadvancedtools/table_json_conversion/fill_xlsx.py +++ b/src/caosadvancedtools/table_json_conversion/fill_xlsx.py @@ -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) -- GitLab