Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions apps/common/handle/impl/table/xls_parse_table_handle.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ def get_content(self, file, save_image):
sheets = workbook.sheets()
md_tables = ''
for sheet in sheets:
# 过滤空白的sheet
if sheet.nrows == 0 or sheet.ncols == 0:
continue

# 获取表头和内容
headers = sheet.row_values(0)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your code looks well-written and should work correctly. However, there is no need to iterate over blank sheets. A better approach would be to skip such sheets directly during the loop instead of after it.

Here's an optimized version:

for sheet in sheets:
    # Get table headers and content only for non-blank sheets
    if sheet.nrows > 0 and sheet.ncols > 0:
        headers = sheet.row_values(0)

This way, you avoid iterating over and processing empty worksheets at all.

Expand Down