diff --git a/src/caosadvancedtools/table_json_conversion/table_generator.py b/src/caosadvancedtools/table_json_conversion/table_generator.py index 5b9c6577b77e4a9c4d2cbfed903d534f4c761f08..07fac8197cbee4d0fa3ce970e5602dd4068dc2c5 100644 --- a/src/caosadvancedtools/table_json_conversion/table_generator.py +++ b/src/caosadvancedtools/table_json_conversion/table_generator.py @@ -28,6 +28,7 @@ from enum import Enum from typing import Dict, List, Optional, Tuple from openpyxl import Workbook +from openpyxl.styles import PatternFill from openpyxl.workbook.child import INVALID_TITLE_REGEX @@ -306,7 +307,11 @@ class XLSXTemplateGenerator(TableTemplateGenerator): self, sheets: Dict[str, Dict[str, Tuple[ColumnType, Optional[str], list]]]): """Create and return a nice workbook for the given sheets.""" wb = Workbook() + yellowfill = PatternFill(fill_type="solid", fgColor='00FFFFAA') assert wb.sheetnames == ["Sheet"] + # remove initial sheet + del wb['Sheet'] + for sheetname, sheetdef in sheets.items(): ws = wb.create_sheet(re.sub(INVALID_TITLE_REGEX, '_', sheetname)) # First row will by the COL_TYPE row. @@ -332,6 +337,9 @@ class XLSXTemplateGenerator(TableTemplateGenerator): for path_index, el in enumerate(path): ws.cell(2 + path_index, 2 + index, el) ws.cell(header_index, 2 + index, colname) + if ct == ColumnType.FOREIGN: + # Visual highlighting + ws.cell(header_index, 2 + index).fill = yellowfill if desc: ws.cell(description_index, 2 + index, desc) @@ -343,9 +351,6 @@ class XLSXTemplateGenerator(TableTemplateGenerator): # hide special column ws.column_dimensions['A'].hidden = True - # remove initial sheet - del wb['Sheet'] - # order sheets # for index, sheetname in enumerate(sorted(wb.sheetnames)): # wb.move_sheet(sheetname, index-wb.index(wb[sheetname]))