en un clic
excel-data-extract
处理各种格式Excel文件的读取方法,特别是面对损坏或不兼容文件时的备选方案
Installer avec Codex ou Claude Copiez ce prompt, collez-le dans Codex, Claude ou un autre assistant, puis laissez-le vérifier la page du skill et l'installer pour vous.
Menu
处理各种格式Excel文件的读取方法,特别是面对损坏或不兼容文件时的备选方案
Installer avec Codex ou Claude Copiez ce prompt, collez-le dans Codex, Claude ou un autre assistant, puis laissez-le vérifier la page du skill et l'installer pour vous.
Basé sur la classification professionnelle SOC
高德地图综合服务,支持POI搜索、路径规划、旅游规划、周边搜索和热力图数据可视化
Knowledge comic creator supporting multiple art styles and tones. Creates original educational comics with detailed panel layouts and sequential image generation. Use when user asks to create "知识漫画", "教育漫画", "biography comic", "tutorial comic", or "Logicomix-style comic".
Generate professional infographics with 21 layout types and 21 visual styles. Analyzes content, recommends layout×style combinations, and generates publication-ready infographics. Use when user asks to create "infographic", "visual summary", "信息图", "可视化", or "高密度信息大图".
Darwin Skill (达尔文.skill): autonomous skill optimizer inspired by Karpathy's autoresearch. Evaluates SKILL.md files using an 8-dimension rubric (structure + effectiveness), runs hill-climbing with git version control, validates improvements through test prompts, and generates visual result cards. Use when user mentions "优化skill", "skill评分", "自动优化", "auto optimize", "skill质量检查", "达尔文", "darwin", "帮我改改skill", "skill怎么样", "提升skill质量", "skill review", "skill打分".
从 DESIGN.md 生成预览图并截图的工作流 - 解决 Playwright 浏览器路径问题和 YAML 解析
Cron jobs auto-deliver final responses to configured targets — send_message to the same target gets deduplicated and skipped. Print report content directly as final response instead.
| name | excel-data-extract |
| title | Excel数据文件读取技巧 |
| description | 处理各种格式Excel文件的读取方法,特别是面对损坏或不兼容文件时的备选方案 |
| trigger | 读取Excel、xlsx文件读取失败、xlrd报错、openpyxl报错 |
| category | data-science |
用户提供的Excel文件可能是:
.xls 文件(BIFF格式,旧版Excel).xlsx 文件(Office Open XML格式).xlsb 文件(二进制格式)有时会遇到:
TypeError: expected <class 'openpyxl.styles.fills.Fill'>XLRDError: Expected BOF recordwith open(path, 'rb') as f:
header = f.read(8)
if header[:8] == b'\xd0\xcf\x11\xe0': # BIFF格式 (.xls)
# 用 xlrd 读取
elif header[:2] == b'PK': # ZIP格式 (.xlsx)
# 用 openpyxl 或手动解析
import xlrd
book = xlrd.open_workbook('file.xls')
sheet = book.sheet_by_index(0)
for i in range(sheet.nrows):
row = [sheet.cell_value(i, j) for j in range(sheet.ncols)]
⚠️ 注意:xlrd 只支持 .xls,不支持 .xlsx
当 openpyxl 报样式表错误时,用纯Python解析(无需依赖):
import zipfile
import xml.etree.ElementTree as ET
def read_xlsx_raw(path):
with zipfile.ZipFile(path, 'r') as z:
# 读取 sharedStrings.xml(字符串表)
strings = []
try:
with z.open('xl/sharedStrings.xml') as f:
tree = ET.parse(f)
root = tree.getroot()
ns = {'main': 'http://schemas.openxmlformats.org/spreadsheetml/2006/main'}
for si in root.findall('.//main:si', ns):
t = si.find('.//main:t', ns)
strings.append(t.text if t is not None else '')
except:
pass
# 读取 sheet1.xml
rows = []
try:
with z.open('xl/worksheets/sheet1.xml') as f:
tree = ET.parse(f)
root = tree.getroot()
ns = {'main': 'http://schemas.openxmlformats.org/spreadsheetml/2006/main'}
for row in root.findall('.//main:row', ns):
cells = []
for cell in row.findall('main:c', ns):
val = cell.find('main:v', ns)
cell_type = cell.get('t') # 's' 表示共享字符串
if val is not None:
v = val.text
if cell_type == 's' and strings:
idx = int(v)
v = strings[idx] if idx < len(strings) else v
cells.append(v)
else:
cells.append('')
if cells:
rows.append(cells)
except Exception as e:
print(f'Error: {e}')
return rows
有些文件开头有 UTF-8 BOM (\xef\xbb\xbf),需要处理:
# xlrd 读取时报错 "Expected BOF record"
# 检查文件是否带BOM
with open(path, 'rb') as f:
header = f.read(10)
if header[:3] == b'\xef\xbb\xbf':
# 文件带BOM,需要用文本模式读取
with open(path, 'r', encoding='utf-8-sig') as f:
content = f.read()
read_only=True 减少内存)本次(2026-05-26)读取5平台数据:
encoding='utf-8-sig' 解决