pythonpython-3.xxlsxxlrd

how to open an xlsx file with xlrd


I am trying to open an xlsx file with xlrd module. the code is like this:

    workbook = xlrd.open_workbook('DAT_XLSX_EURUSD_M1_2018.xlsx')

But I this error:

    AttributeError: module 'xlrd' has no attribute 'xlsx'

It was suggested to use the code below to prevent this error form happening but, it did no help

    xlrd.xlsx.ensure_elementtree_imported(False, None)
    xlrd.xlsx.Element_has_iter = True

My xlrd version is 2.0.1


Solution

  • Apparently, xlrd version 2.0.1 does not support xlsx files and works with xls files. I downloaded xlrd 1.2.0 and It opened my xlsx files without any error.