Problem: Xlrd add formatting_info=true error when reading Excel
Before we used to read the XLS file is the use of the XLRD library, but this library can only operate. xls format, for later. xlsx version support is not too good:
For example: When you use XLRD to load xlsx files, you add the
Xlrd.open_workbook (FilePath, Formatting_info=true)
Formatting_info=true is used to save excel in its original format.
You will get this error prompt immediately:
Traceback (most recent call last):
File "xxxxxxxx\test_read_excel_color.py", line 7, in <module>
xlrd.open_workbook(r'./xxxxx.xlsx',formatting_info=True)
File "C:\Python27\lib\site-packages\xlrd\__init__.py", line 422, in open_workbook
ragged_rows=ragged_rows,
File "C:\Python27\lib\site-packages\xlrd\xlsx.py", line 751, in open_workbook_2007_xml
raise NotImplementedError("formatting_info=True not yet implemented")
NotImplementedError: formatting_info=True not yet implemented
Formatting_info's explanation in the official website is:
> formatting_info –
The default is False, which saves memory. In this case, “Blank” cells, which are those with their own formatting information but no data, are treated as empty by ignoring the file’s BLANK and MULBLANK records. This cuts off any bottom or right “margin” of rows of empty or blank cells. Only cell_value() and cell_type() are available.
This option is used with memory saving. In this case, empty cells, which have formatting information but no data, will be treated as empty. This will crop out any bottom, right "edge" empty table. Only Cell_value () and Cell_type are valid.
In fact, when the option is closed, the following problem occurs when the program needs to load the color code in the cell.
Traceback (most recent call last):
File "xxxxx\test_read_execel_color1.py", line 10, in <module>
xf_idx = xws1.cell_xf_index(0,0)
File "C:\Python27\lib\site-packages\xlrd\sheet.py", line 420, in cell_xf_index
self.req_fmt_info()
File "C:\Python27\lib\site-packages\xlrd\sheet.py", line 1664, in req_fmt_info
raise XLRDError("Feature requires open_workbook(..., formatting_info=True)")
XLRDError: Feature requires open_workbook(..., formatting_info=True)
I don't know if there are any other problems in there. With this option turned off, some xlrd code would not be able to write like this.
Solutions
- Save excel in. xlsx format as. xls format; PS: Modifying the. xlsx file suffix directly to. xls is not feasible.
- Use the OPENPYXL library to read the XLSX configuration table.
Python module Learning xlrd reading Excel Xlrd.open_workbook (filepath,formatting_info=true) Error: Notimplementederror:formatting_ Info=true not yet implemented