Reputation: 61
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
Upvotes: 5
Views: 20473
Reputation: 63
The issue generally occurs when the sheet is formatted with a "Freeze Pane".
See Menu -> View -> Freeze Panes
Removing the Panes in Excel will resolve the issue.
Upvotes: 0
Reputation: 12232
You can influence the UserWarings using the warnings module. Also see Ignore UserWarning from openpyxl using pandas
import warnings
warnings.filterwarnings('ignore', category=UserWarning, module='openpyxl')
Upvotes: 3
Reputation: 73
To get rid of this warning, change your load_workbook
call to this:
wb1 = load_workbook(filename=path, read_only=True)
Upvotes: 3
Reputation: 188
"""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.
Upvotes: 8