13

Why do I receive this warning message every time I run my code? (below). Is it possible to get rid of it? If so, how do I do that?

My code:

from openpyxl import load_workbook
from openpyxl import Workbook

wb = load_workbook('NFL.xlsx', data_only = True)
ws = wb.active
sh = wb["Sheet1"]


ptsDiff = (sh['J127'].value)
print ptsDiff

The code works but I get this warning message:

Warning (from warnings module):
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/openpyxl/reader/worksheet.py", line 320
warn(msg)
UserWarning: Unknown extension is not supported and will be removed
2
  • Where is this xlsx file coming from? What tool was used to create it? Thanks. Commented Dec 16, 2015 at 21:38
  • The .xlsx file is coming from the same folder as the python file. I created it using Microsoft Excel for Mac 2011(version 14.5.9). Commented Dec 16, 2015 at 21:48

5 Answers 5

11

This error happens when openpyxl cannot understand/read an extension (source). Here is the list of built-in extensions openpyxl currently knows that is doesn't support:

  • Conditional Formatting
  • Data Validation
  • Sparkline Group
  • Slicer List
  • Protected Range
  • Ignored Error
  • Web Extension
  • Slicer List
  • Timeline Ref

Also see the Worksheet extension list specification.

Sign up to request clarification or add additional context in comments.

9 Comments

Sorry for my ignorance but are you saying that openpyxl cannot understand/read .xlsx files? If I were to add read_only = True to this line.. wb = load_workbook('NFL.xlsx', read_only = True, data_only = True). I no longer receive this warning message.
@jcmcdonald nope, I'm saying there is an extension/feature used inside the file that openpyxl cannot understand. And, yes, if you need data only, date_only would make it not parse the extensions at all. Hope that helps.
Sorry again. Is there away to avoid the warning?
The warnings refer to extensions that Microsoft has added to the file format since 2006. They are not covered by the specification.
How do I handle the Warning? Also, can I determine the offending built-in extension? How would I do that?
|
4

Try to add single quotes to your data_only parameter like this:

wb = load_workbook('NFL.xlsx', data_only = **'True'**)

This works for me.

1 Comment

Wow. That is the trick, indeed. Dirty secret.
1

Using python 3.5 under Anaconda3, Excel 2016, Windows10 -- I had the same problem initially with an xlsx file. Tried to make it into a csv and did not work. What worked was: select the entire spreadsheet, copy on a Notepad, select the notepad text, paste in a new spreadsheet, save as xslx. It looks like any extra formatting would result in a warning.

1 Comment

Modifying the shreadsheet is not always possible.
1

I was trying to use Openpyxl to do something that has nothing to do with charts or graphs. I got warning message: UserWarning: DrawingML support is incomplete and limited to charts and images only. Shapes and drawings will be lost.

In the line that opens pyxl workbook, I added a parameter that ReadOnly = True Being ReadOnly, I can't try to alter graphs, etc.; and the warning seems to be gone now.

Sharing it here because this is the first help page I see where I can add a comment; and internet searching was not serving me up an answer.

Comments

-1

It is already listed in the first answer what is wrong with it If you only want to get rid of the error that is given in red for some reason. You can go to the file location of the error and # the line where is says warn(msg) this will stop the error being displayed the code still works fine in my experience.I am not sure if this will work after compiled but this should work in the same machine. PS:I had the same error and this is what I did because I though it could be confusing for the end user PS:You can use a try and except error catcher too but this is quicker.

3 Comments

yeah i know but i get the output I want and I need to hide error i couldnt find a way to get rid of it so I did it that way
This is a horrible idea as you'd be editing an installed package directly, which can interfere with updates and reproducibility of your code.
As openpyxl uses the Python warnings library for its warnings, there's a better method here for suppressing these warnings in specific sections of the code, or see here for globally disabling warnings when running Python (also other answers therein, especially this

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.