Cant find workbook in ole2 compound document

After a lot of searching, the only way I've found to do this is to open and save all the excel documents, which seems to 'strip' them of their OLE2 format. I automated the process with the following vbs script:

Dim objFSO, objFolder, objFile
Dim objExcel, objWB
Set objExcel = CreateObject("Excel.Application")
Set objFSO = CreateObject("scripting.filesystemobject")
MyFolder = "<PATH /TO/FILES" Set objFolder=objfso.getfolder(myfolder) For Each objFile In objfolder.Files If Right(objFile.Name,4)="<EXTENSION>" Then Set objWB=objExcel.Workbooks.Open(objFile) objWB.save objWB.close End If Next objExcel.Quit Set objExcel=Nothing Set objFSO=Nothing Wscript.Echo "Done"


Suggestion : 2

xlrd.biffh.XLRDError: Can't find workbook in anycodings_excel OLE2 compound document,I have a script that reads an xlsx excel anycodings_excel file that was working fine until a week ago. anycodings_excel The error message is:,How to add custom component in formio using angular same as premium data source comp,"Expected an assignment or function call and instead saw an expression" inside setTimeout

By debugging the script, I've found the anycodings_excel whole stack:

C: \MyFolder\ MyScript.py ", line 42, in PandasReadExcel 
ef = pd.read_excel(excfile, sheetname, header, skiprows)
File "C:\Python\Python36\lib\site-packages\pandas\io\excel.py", line 191, in read_excel
io = ExcelFile(io, engine = engine)
File "C:\Python\Python36\lib\site-packages\pandas\io\excel.py", line 249, in __init__
self.book = xlrd.open_workbook(io)
File "C:\Python\Python36\lib\site-packages\xlrd\__init__.py", line 441, in open_workbook
ragged_rows = ragged_rows, File "C:\Python\Python36\lib\site-packages\xlrd\book.py", line 87, in open_workbook_xls
ragged_rows = ragged_rows,
   File "C:\Python\Python36\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

After months struggling with this error, anycodings_xlrd I've learned that the concerned files anycodings_xlrd are being edited using an older version anycodings_xlrd of Microsoft Office (namely Office 2007, anycodings_xlrd in this very case). Then I decided to anycodings_xlrd implement a clumsy workaround anycodings_xlrd solution: Just open the files using a anycodings_xlrd compatible Excel version, and save a anycodings_xlrd copy in a different folder; then open anycodings_xlrd the file using pandas read_excel anycodings_xlrd function, it should open normally! To anycodings_xlrd automate this task I wrote a powershell anycodings_xlrd script just to open the original file anycodings_xlrd and save the copy. This script must be anycodings_xlrd executed according to how often the data anycodings_xlrd is updated:

$FileName = "\\path\to\the\source\file.xlsx"
$FileNameCopy = "\\path\to\the\copy\file.xlsx"

$xl = New - Object - comobject Excel.Application
# repeat this
for every file concerned
$wb = $xl.Workbooks.open("$FileName", 3)
$wb.SaveAs($FileNameCopy)
$wb.Close($False)

$xl.Quit()


Suggestion : 3

Pandas open_excel() fails with xlrd.biffh.XLRDError: Can't find workbook in OLE2 compound document,Pandas IndexSlice fails with pd.style,I don't think that pd.IndexSlice even does anything except wrap the contents in a tuple for this second case. You can just do this:,change multi level index fonts with pandas style function

This is not what we get with the first slice:

In[1]: pd.IndexSlice[1: -1,: -1]
Out[2]: (slice(1, -1, None), slice(None, -1, None))

but we do get something of that form from the second slice method:

In[3]: pd.IndexSlice[df.index[1: -1], df.columns[: -1]]
Out[4]: (Index(['B', 'C'], dtype = 'object'), Index([2011, 2012, 2013], dtype = 'object'))

I don't think that pd.IndexSlice even does anything except wrap the contents in a tuple for this second case. You can just do this:

df.style.bar(subset = (df.index[1: -1], df.columns[: -1]),
   color = '#d65f5f')


Suggestion : 4

03/11/2022

You are have xlrd installed on your cluster and are attempting to read files in the Excel .xlsx format when you get an error.

XLRDError: Excel xlsx file;
not supported

Confirm that you are using pandas version 1.0.1 or above.

import pandas as pd
print(pd.__version__)

Specify openpyxl when reading .xlsx files with pandas.

import pandas
df = pandas.read_excel(`<name-of-file>.xlsx`, engine=`openpyxl`)

Confirm that you are using pandas version 1.0.1 or above.

import pandas as pd
print(pd.__version__)

Specify openpyxl when reading .xlsx files with pandas.

import pandas
df = pandas.read_excel(`<name-of-file>.xlsx`, engine=`openpyxl`)