diff --git a/poetry.lock b/poetry.lock index 357a07c..4f09c6e 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1563,13 +1563,13 @@ telegram = ["requests"] [[package]] name = "types-openpyxl" -version = "3.1.5.20241114" +version = "3.1.5.20241126" description = "Typing stubs for openpyxl" optional = false python-versions = ">=3.8" files = [ - {file = "types-openpyxl-3.1.5.20241114.tar.gz", hash = "sha256:caeb9aafed8a5ffabdc74f880b148d90375364a1cfe7915d5065c5d79f3fe6a2"}, - {file = "types_openpyxl-3.1.5.20241114-py3-none-any.whl", hash = "sha256:f2925f595b08f5aef1baa725c9ee40baaf51beb05d98ac150593d3bdd37b1029"}, + {file = "types_openpyxl-3.1.5.20241126-py3-none-any.whl", hash = "sha256:e50ad5c2dec2c92cca521abed5c039975226e8e76389f17ab0ef813595593fbe"}, + {file = "types_openpyxl-3.1.5.20241126.tar.gz", hash = "sha256:f599afab19f87aa11672ee675346401d82a0dac71988df9a5411cdb1e7477377"}, ] [[package]] diff --git a/suisa_sendemeldung/suisa_sendemeldung.py b/suisa_sendemeldung/suisa_sendemeldung.py index 831dbe8..e81fe2f 100644 --- a/suisa_sendemeldung/suisa_sendemeldung.py +++ b/suisa_sendemeldung/suisa_sendemeldung.py @@ -28,6 +28,7 @@ from dateutil.relativedelta import relativedelta from iso3901 import ISRC from openpyxl import Workbook +from openpyxl.cell.cell import Cell, MergedCell from openpyxl.styles import Border, Font, PatternFill, Side from tqdm import tqdm @@ -693,9 +694,10 @@ def get_xlsx(data: Any, args: ArgparseNamespace) -> BytesIO: # noqa: ANN401 # Try to approximate the required width by finding the longest values per column dims: dict[str, int] = {} - for row in worksheet.rows: # type: ignore[assignment] - for cell in row: # type: ignore[assignment] - if cell.value: + calc_row: tuple[Cell | MergedCell, ...] + for calc_row in worksheet.rows: + for cell in calc_row: + if isinstance(cell, Cell) and cell.value: dims[cell.column_letter] = max( (dims.get(cell.column_letter, 0), len(str(cell.value))), )