UserWarning: "Cannot parse header or footer so it will be ignored" on loading xlsm file

Viewed 9928

Trying to open xlsm file using python

Below is the code :

import libraries
import openpyxl
from openpyxl import load_workbook
from openpyxl import Workbook
from openpyxl.styles import colors
from openpyxl.styles import Color, PatternFill, Font, Border

#path of the source sheet
path = "C:\DATA\PYTHON\Practise\SysTSAutSW300PFCRebuildDemo.xlsm"
wb1 = load_workbook(path)

sheet = wb1.get_sheet_by_name('PFC_Rebuild')

celldata = sheet['L33']

print celldata

It gives the below error :

Warning (from warnings module): File "C:\Python27\lib\site-packages\openpyxl\worksheet\header_footer.py", line 49 warn("""Cannot parse header or footer so it will be ignored""") UserWarning: Cannot parse header or footer so it will be ignored

2 Answers

"""Cannot parse header or footer so it will be ignored"""

The warning occurred because you have an header or footer on your excel file that can't be parsed by openpyxl. If you want to get rid of the warning, you can remove the header and footer from the excel file with

File -> Info -> Check for Issues -> Inspect Document -> Remove your header and footer.

To get rid of this warning, change your load_workbook call to this:

wb1 = load_workbook(filename=path, read_only=True)
Related