Skip to content
Snippets Groups Projects

Draft: Automatic XLSX export

Open I. Nüske requested to merge f-enh-143-automatic-xlsx-exporting into dev
12 unresolved threads
@@ -92,8 +92,6 @@ def _generate_jsondata_from_records(records: Container,
The given records data in json form.
"""
json_data = {}
# Ignore warning from high_level_api to avoid raising warnings that cannot
# be avoided by user
for record in records:
# Convert records to high level api objects
record_obj = convert_to_python_object(record)
@@ -196,8 +194,10 @@ def export_container_to_xlsx(records: Container,
# Retrieve data
new_records = []
for entity_id in entity_ids:
entity_id = str(entity_id).split('@')[0]
entity_id = str(entity_id).split('@')[0] # Queries cannot handle version
entity = execute_query(f"FIND ENTITY WITH (ID = {entity_id})", unique=True)
# We can currently only handle Entities with a parent, as otherwise we
# do not know which sheet they belong in.
if len(entity.get_parents()) > 0:
new_records.append(entity)
# ToDo: Handle Files and other Entities (e.g. Properties) separately
@@ -212,7 +212,9 @@ def export_container_to_xlsx(records: Container,
json_schema = _generate_jsonschema_from_recordtypes(recordtypes,
jsonschema_filepath)
json_data = _generate_jsondata_from_records(records, jsondata_filepath)
# Generate xlsx template with tempfile if necessary
# Generate xlsx template
# _generate_xlsx_template_file needs a file name, so use NamedTemporaryFile
# ToDo: This might not work on windows, if not, fix _generate file handling
if xlsx_template_filepath is None:
xlsx_template_file = tempfile.NamedTemporaryFile(suffix='.xlsx')
xlsx_template_filepath = xlsx_template_file.name
Loading