Skip to content

Commit

Permalink
fix(xl_app): Refactor XL App and Fix font / background color issue
Browse files Browse the repository at this point in the history
  • Loading branch information
ed-p-may committed Dec 15, 2022
1 parent 063789f commit 6e2176d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
21 changes: 16 additions & 5 deletions PHX/PHPP/sheet_io/io_areas.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,23 @@ def get_surface_phpp_id_by_name(self, _name: str, _use_cache: bool = False) -> s
)

# -- Figure out the right full PHPP name, with the ID-number prefix
prefix = self.xl.get_data(
self.shape.name,
f"{col_offset(str(self.shape.surface_rows.inputs.description.column), -1)}{row}",
)
prefix_range = f"{col_offset(str(self.shape.surface_rows.inputs.description.column), -1)}{row}"
prefix_value = self.xl.get_data(self.shape.name, prefix_range)

try:
prefix_value = str(prefix_value) # prefix_value comes in from excel as "1.0"
prefix_value = float(prefix_value) # Can't convert "1.0" -> 1 directly??
prefix_value = int(prefix_value)
except:
msg = (
f"\n\tError: Something went wrong trying to find the PHPP-ID "
f"number for the surface: '{_name}'? Expected to find an integer "
f"value but got: '{prefix_value}' at {self.shape.name}:{prefix_range}"
)
raise Exception(msg)

self.xl.output(f"Getting PHPP Surface id for {_name}")
name = f"{int(str(prefix))}-{_name}"
name = f"{prefix_value}-{_name}"

# -- Save in cache
self.surface_cache[_name] = name
Expand Down
6 changes: 3 additions & 3 deletions PHX/xl/xl_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,9 +511,9 @@ def write_xl_item(self, _xl_item: Union[xl_data.XlItem, xl_data.XLItem_List]) ->
_xl_range = xl_range.offset(column_offset=i)
_xl_range.color = _xl_item.range_color
_xl_range.font.color = _xl_item.font_color
else:
xl_range.color = _xl_item.range_color
xl_range.font.color = _xl_item.font_color
else:
xl_range.color = _xl_item.range_color
xl_range.font.color = _xl_item.font_color

except AttributeError as e:
raise AttributeError(e)
Expand Down
2 changes: 1 addition & 1 deletion PHX/xl/xl_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def write_value(self) -> xl_writable:
@property
def has_color(self) -> bool:
"""Return True if the Item has font or background color values."""
if self.font_color or self.range_color:
if self.font_color and self.range_color:
return True
return False

Expand Down

0 comments on commit 6e2176d

Please sign in to comment.