0
我想用python熊貓打開一個Excel文件。代碼很簡單,如下所示;熊貓無法打開這個Excel文件
import pandas as pd
df = pd.read_excel('../TestXLWings.xlsm', sheetname="TestSheet")
我在下面的錯誤;
Traceback (most recent call last):
File "C:\Program Files\JetBrains\PyCharm Community Edition 2017.2\helpers\pydev\pydevd.py", line 1599, in <module>
globals = debugger.run(setup['file'], None, None, is_module)
File "C:\Program Files\JetBrains\PyCharm Community Edition 2017.2\helpers\pydev\pydevd.py", line 1026, in run
pydev_imports.execfile(file, globals, locals) # execute the script
File "C:\Program Files\JetBrains\PyCharm Community Edition 2017.2\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "C:/Users/testing/Dropbox/Test-XLwings/test.py", line 3, in <module>
df = pd.read_excel('../TestXLWings.xlsm', sheetname="TestSheet")
File "C:\ProgramData\Anaconda3\lib\site-packages\pandas\io\excel.py", line 203, in read_excel
io = ExcelFile(io, engine=engine)
File "C:\ProgramData\Anaconda3\lib\site-packages\pandas\io\excel.py", line 260, in __init__
self.book = xlrd.open_workbook(io)
File "C:\ProgramData\Anaconda3\lib\site-packages\xlrd\__init__.py", line 441, in open_workbook
ragged_rows=ragged_rows,
File "C:\ProgramData\Anaconda3\lib\site-packages\xlrd\book.py", line 87, in open_workbook_xls
ragged_rows=ragged_rows,
File "C:\ProgramData\Anaconda3\lib\site-packages\xlrd\book.py", line 595, in biff2_8_load
raise XLRDError("Can't find workbook in OLE2 compound document")
xlrd.biffh.XLRDError: Can't find workbook in OLE2 compound document
我的Excel文件是xlsm並受密碼保護。 OLE2複合文檔究竟意味着什麼?熊貓在打開這種Excel文件時是否有問題?我正在使用python v3.6
我正在使用xlrd 1.0.0。這是最新版本。我剛剛做了一個'conda更新' – user781486
我以前遇到過受保護文件的類似問題。文件上是否有任何保護/鎖定? – ayhan
@ayhan,Excel文件受密碼保護。 – user781486