简体   繁体   English

pd.read_excel 无法读取 xlsm 文件

[英]pd.read_excel can't read xlsm file

I use below code to read xlsm file:我使用下面的代码来读取 xlsm 文件:

df = pd.read_excel(filepath,target_worksheet)

but it doesn't work, the error message is:但它不起作用,错误消息是:
XLRDError: Can't find workbook in OLE2 compound document . XLRDError: Can't find workbook in OLE2 compound document

Pandas official website mentions that it supports xlsm file, as link . Pandas官网提到它支持xlsm文件,作为链接 I am wondering whether my conclusion is correct or not.我想知道我的结论是否正确。

Then I use win32com, which can open the excel file and extract the data for cells, but it seems that it can't be read as DataFrames.然后我用win32com,可以打开excel文件,提取单元格的数据,但是好像不能作为DataFrames读取。

Is there any solution to read xlsm file to DataFrame?有没有办法将xlsm文件读取到DataFrame? Thanks.谢谢。

Thank you.谢谢你。

Pandas does support xlsm files. Pandas 确实支持 xlsm 文件。

That error often happens when you are trying to access password protected Excel files, Here you have a workaround if that's your case:当您尝试访问受密码保护的 Excel 文件时,通常会发生该错误,如果是这种情况,您可以在这里找到解决方法:

https://davidhamann.de/2018/02/21/read-password-protected-excel-files-into-pandas-dataframe/ https://davidhamann.de/2018/02/21/read-password-protected-excel-files-into-pandas-dataframe/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM