python打不开xls文件,用wps下vba解决问题
用了常用的三种python读写xls文件的方法都报错
xlrd
代码
book = xlrd.open_workbook(filename)
报错
xlrd.biffh.XLRDError: Unsupported format, or corrupt file: Expected BOF record; found b'<html xm'
openpyxl
代码
book = openpyxl.load_workbook(filename)
报错
openpyxl.utils.exceptions.InvalidFileException: openpyxl does not support the old .xls file format, please use xlrd to read this file, or convert it to the more recent .xlsx file format.
pandas
代码
book = pd.read_excel(filename)
报错
xlrd.biffh.XLRDError: Unsupported format, or corrupt file: Expected BOF record; found b'<html xm'
原因
可能是由于要打开的xls文件不是标准的97-03版