diff --git a/lotemplate/Statement/TableStatement.py b/lotemplate/Statement/TableStatement.py index 5eaf726..c4ddc6d 100644 --- a/lotemplate/Statement/TableStatement.py +++ b/lotemplate/Statement/TableStatement.py @@ -1,5 +1,5 @@ from com.sun.star.lang import XComponent -from com.sun.star.sheet import XCellRangeData +from com.sun.star.uno import RuntimeException from typing import Union import lotemplate.errors as errors import regex @@ -47,15 +47,18 @@ def scan_cell(cell) -> None: tab_vars = {} list_tab_vars = [] for i in range(doc.getTextTables().getCount()): - table = doc.getTextTables().getByIndex(i) - if not isinstance(table, XCellRangeData): + try: + table_data = doc.getTextTables().getByIndex(i).getDataArray() + t_name = doc.getTextTables().getByIndex(i).getName() + nb_rows = len(table_data) + for row_i, row in enumerate(table_data): + for column in row: + scan_cell(column) + except errors.TemplateError as e: + raise e + continue + except RuntimeException as e: continue - table_data = table.getDataArray() - t_name = doc.getTextTables().getByIndex(i).getName() - nb_rows = len(table_data) - for row_i, row in enumerate(table_data): - for column in row: - scan_cell(column) return list_tab_vars if get_list else tab_vars