Search code examples
pythonexcelxlwings

How to force xlwings to use COMRetryObjectWrapper instead of win32com api?


I recently had to reformat my computer, and now whenever I try to call the Sheet.api property in xlwings, I get the following result:

>>> wb = xw.Book('<path-to-wb>')
>>> sht = wb.sheets['Sheet1']
>>> sht.api
    <win32com.gen_py.Microsoft Excel 16.0 Object Library._Worksheet instance at 0x1293314650312>

Previously, sht.api returned me a <xlwings._xlwindows.COMRetryObjectWrapper at 0x1e816dda7c8> object.

Is this some kind of windows configuration that I have to restore? Why is xlwings behaving differently all of a sudden?


Solution

  • This isn't all of a sudden but the effect of upgrading to a new version where the RetryObjectWrapper is printed with more meaningful information. It's still the same object though as you will see when you print its type:

    >>> type(sht.api)
    <class 'xlwings._xlwindows.COMRetryObjectWrapper'>