mirror of
https://github.com/DS4SD/docling.git
synced 2025-08-01 15:02:21 +00:00
reformatted the code
Signed-off-by: Peter Staar <taa@zurich.ibm.com>
This commit is contained in:
parent
f837105a09
commit
d23aea981d
@ -177,7 +177,7 @@ class MsExcelDocumentBackend(DeclarativeDocumentBackend):
|
|||||||
"""
|
"""
|
||||||
Find all compact rectangular data tables in a sheet.
|
Find all compact rectangular data tables in a sheet.
|
||||||
"""
|
"""
|
||||||
#_log.info("find_data_tables")
|
# _log.info("find_data_tables")
|
||||||
|
|
||||||
tables = [] # List to store found tables
|
tables = [] # List to store found tables
|
||||||
visited: set[Tuple[int, int]] = set() # Track already visited cells
|
visited: set[Tuple[int, int]] = set() # Track already visited cells
|
||||||
@ -230,11 +230,15 @@ class MsExcelDocumentBackend(DeclarativeDocumentBackend):
|
|||||||
row_span = 1
|
row_span = 1
|
||||||
col_span = 1
|
col_span = 1
|
||||||
|
|
||||||
#_log.info(sheet.merged_cells.ranges)
|
# _log.info(sheet.merged_cells.ranges)
|
||||||
for merged_range in sheet.merged_cells.ranges:
|
for merged_range in sheet.merged_cells.ranges:
|
||||||
|
|
||||||
if merged_range.min_row<=ri+1 and ri+1<=merged_range.max_row and \
|
if (
|
||||||
merged_range.min_col<=rj+1 and rj+1<=merged_range.max_col:
|
merged_range.min_row <= ri + 1
|
||||||
|
and ri + 1 <= merged_range.max_row
|
||||||
|
and merged_range.min_col <= rj + 1
|
||||||
|
and rj + 1 <= merged_range.max_col
|
||||||
|
):
|
||||||
|
|
||||||
row_span = merged_range.max_row - merged_range.min_row + 1
|
row_span = merged_range.max_row - merged_range.min_row + 1
|
||||||
col_span = merged_range.max_col - merged_range.min_col + 1
|
col_span = merged_range.max_col - merged_range.min_col + 1
|
||||||
@ -243,8 +247,8 @@ class MsExcelDocumentBackend(DeclarativeDocumentBackend):
|
|||||||
if (ri, rj) not in visited_cells:
|
if (ri, rj) not in visited_cells:
|
||||||
data.append(
|
data.append(
|
||||||
ExcelCell(
|
ExcelCell(
|
||||||
row = ri - start_row,
|
row=ri - start_row,
|
||||||
col = rj - start_col,
|
col=rj - start_col,
|
||||||
text=str(cell.value),
|
text=str(cell.value),
|
||||||
row_span=row_span,
|
row_span=row_span,
|
||||||
col_span=col_span,
|
col_span=col_span,
|
||||||
@ -266,7 +270,7 @@ class MsExcelDocumentBackend(DeclarativeDocumentBackend):
|
|||||||
visited_cells,
|
visited_cells,
|
||||||
)
|
)
|
||||||
|
|
||||||
def _find_table_bottom(self, sheet: Worksheet, start_row:int, start_col:int):
|
def _find_table_bottom(self, sheet: Worksheet, start_row: int, start_col: int):
|
||||||
"""Function to find the bottom boundary of the table"""
|
"""Function to find the bottom boundary of the table"""
|
||||||
|
|
||||||
max_row = start_row
|
max_row = start_row
|
||||||
@ -286,13 +290,13 @@ class MsExcelDocumentBackend(DeclarativeDocumentBackend):
|
|||||||
|
|
||||||
# Expand max_row to include the merged range if applicable
|
# Expand max_row to include the merged range if applicable
|
||||||
if merged_range:
|
if merged_range:
|
||||||
max_row = max(max_row, merged_range.max_row-1)
|
max_row = max(max_row, merged_range.max_row - 1)
|
||||||
else:
|
else:
|
||||||
max_row += 1
|
max_row += 1
|
||||||
|
|
||||||
return max_row
|
return max_row
|
||||||
|
|
||||||
def _find_table_right(self, sheet: Worksheet, start_row:int, start_col:int):
|
def _find_table_right(self, sheet: Worksheet, start_row: int, start_col: int):
|
||||||
"""Function to find the right boundary of the table"""
|
"""Function to find the right boundary of the table"""
|
||||||
|
|
||||||
max_col = start_col
|
max_col = start_col
|
||||||
@ -312,13 +316,12 @@ class MsExcelDocumentBackend(DeclarativeDocumentBackend):
|
|||||||
|
|
||||||
# Expand max_col to include the merged range if applicable
|
# Expand max_col to include the merged range if applicable
|
||||||
if merged_range:
|
if merged_range:
|
||||||
max_col = max(max_col, merged_range.max_col-1)
|
max_col = max(max_col, merged_range.max_col - 1)
|
||||||
else:
|
else:
|
||||||
max_col += 1
|
max_col += 1
|
||||||
|
|
||||||
return max_col
|
return max_col
|
||||||
|
|
||||||
|
|
||||||
def _find_images_in_sheet(
|
def _find_images_in_sheet(
|
||||||
self, doc: DoclingDocument, sheet: Worksheet
|
self, doc: DoclingDocument, sheet: Worksheet
|
||||||
) -> DoclingDocument:
|
) -> DoclingDocument:
|
||||||
|
Loading…
Reference in New Issue
Block a user