try:
# 如果是您提供的示例格式,可以直接使用以下数据
# 实际应用中应该从文件读取
df = pd.read_excel(input_file_path,engine='xlrd')
print(f"df数据内容: {df}")
# df = pd.DataFrame(data)
except Exception as e:
print(f"读取文件错误: {e}")
return False
2、报错信息
Unsupported format, or corrupt file: Expected BOF record; found b'<?xml ve'
3、问题原因
参阅了网上资料: https://stackoverflow.com/questions/9623029/python-xlrd-unsupported-format-or-corrupt-file
有一段这样的话:
However as the error message says, the first 8 bytes of the file are '<table r' ... that is definitely not Excel .xls format. Open it with a text editor (e.g. Notepad) that won't take any notice of the (incorrect) .xls extension and see for yourself.
意思是说,这个文件不是个excel文件,虽然以.xls结尾,但是内部格式不对,不信你用文本编辑器打开看看,
结果我打开是这样的:
而正常的xls文件是这样的:
4、结论
从系统导出的excel文件是html文件,不是原生的excel文件,需要用wps打开另存为重新保存下生成原生的excel文件
文中提到 Could have been saved as XML Spreadsheet (*.xml) (not supported by xlrd)
是xlrd不支持这种方式的excel文件



5358

被折叠的 条评论
为什么被折叠?



