"""使用 unstructured 库解析 XLSX 文件""" from typing import Optional, Tuple from scripts.readers._utils import convert_unstructured_to_markdown def parse(file_path: str) -> Tuple[Optional[str], Optional[str]]: """使用 unstructured 库解析 XLSX 文件""" try: from unstructured.partition.xlsx import partition_xlsx except ImportError: return None, "unstructured 库未安装" try: elements = partition_xlsx(filename=file_path, infer_table_structure=True) content = convert_unstructured_to_markdown(elements) if not content.strip(): return None, "文档为空" return content, None except Exception as e: return None, f"unstructured 解析失败: {str(e)}"