docsmith-mcp 0.0.1-beta.3 → 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/python/excel_handler.py +14 -0
package/package.json
CHANGED
package/python/excel_handler.py
CHANGED
|
@@ -11,8 +11,22 @@ def read_excel(file_path: str, sheet_name: str = None, page: int = None, page_si
|
|
|
11
11
|
|
|
12
12
|
wb = openpyxl.load_workbook(file_path, data_only=True)
|
|
13
13
|
|
|
14
|
+
# Handle sheet_name selection
|
|
14
15
|
if sheet_name is None:
|
|
16
|
+
# Use first sheet if not specified
|
|
15
17
|
sheet_name = wb.sheetnames[0]
|
|
18
|
+
elif sheet_name not in wb.sheetnames:
|
|
19
|
+
# If sheet_name not found, try to interpret as 1-based index
|
|
20
|
+
try:
|
|
21
|
+
sheet_index = int(sheet_name) - 1
|
|
22
|
+
if 0 <= sheet_index < len(wb.sheetnames):
|
|
23
|
+
sheet_name = wb.sheetnames[sheet_index]
|
|
24
|
+
else:
|
|
25
|
+
# Index out of range, use first sheet
|
|
26
|
+
sheet_name = wb.sheetnames[0]
|
|
27
|
+
except (ValueError, IndexError):
|
|
28
|
+
# Not a valid number or other error, use first sheet
|
|
29
|
+
sheet_name = wb.sheetnames[0]
|
|
16
30
|
|
|
17
31
|
ws = wb[sheet_name]
|
|
18
32
|
|