1

I cannot identify why I am getting this error. Does anybody know what is the reason for such error?

Traceback (most recent call last): File "c:/Users/g401428/Documents/Visual Studio Code/jackpotCalc/calculationFGTriggerProb.py", line 49, in <module> wb1 = load_workbook(excel_mb_path , read_only=True, keep_vba=False, data_only=True, keep_links=False) File "C:\Users\g401428\AppData\Local\Continuum\anaconda3\lib\site-packages\openpyxl\reader\excel.py", line 312, in load_workbook reader.read() File "C:\Users\g401428\AppData\Local\Continuum\anaconda3\lib\site-packages\openpyxl\reader\excel.py", line 273, in read apply_stylesheet(self.archive, self.wb) File "C:\Users\g401428\AppData\Local\Continuum\anaconda3\lib\site-packages\openpyxl\styles\stylesheet.py", line 189, in apply_stylesheet stylesheet = Stylesheet.from_tree(node) File "C:\Users\g401428\AppData\Local\Continuum\anaconda3\lib\site-packages\openpyxl\styles\stylesheet.py", line 103, in from_tree return super(Stylesheet, cls).from_tree(node) File "C:\Users\g401428\AppData\Local\Continuum\anaconda3\lib\site-packages\openpyxl\descriptors\serialisable.py", line 88, in from_tree obj = desc.expected_type.from_tree(el) File "C:\Users\g401428\AppData\Local\Continuum\anaconda3\lib\site-packages\openpyxl\descriptors\serialisable.py", line 88, in from_tree obj = desc.expected_type.from_tree(el) File "C:\Users\g401428\AppData\Local\Continuum\anaconda3\lib\site-packages\openpyxl\descriptors\serialisable.py", line 88, in from_tree obj = desc.expected_type.from_tree(el) File "C:\Users\g401428\AppData\Local\Continuum\anaconda3\lib\site-packages\openpyxl\descriptors\serialisable.py", line 104, in from_tree return cls(**attrib) File "C:\Users\g401428\AppData\Local\Continuum\anaconda3\lib\site-packages\openpyxl\styles\alignment.py", line 59, in __init__ self.textRotation = int(textRotation) File "C:\Users\g401428\AppData\Local\Continuum\anaconda3\lib\site-packages\openpyxl\descriptors\base.py", line 145, in __set__ super(NoneSet, self).__set__(instance, value) File "C:\Users\g401428\AppData\Local\Continuum\anaconda3\lib\site-packages\openpyxl\descriptors\base.py", line 130, in __set__ raise ValueError(self.__doc__) ValueError: Value must be one of {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180} 

I am getting this error with this code:

excel_mb_path = "C:\\Users\\Book1.xlsx"

wb1 = load_workbook(excel_mb_path , read_only=True, keep_vba=False, data_only=True, keep_links=False)

What is interesting is that with other excel file I do not get this error... Therefore I am curious what is the problem with a completely "new excel", with one sheet and one table that I am trying to read... and other excel into which I just copied the values, not the whole sheet the code works.

4
  • Without an example .xls file which contains this error it is hard to give an answer. The best we can do is guess. Commented Nov 12, 2019 at 10:35
  • The file is possibly invalid. Can't say more without looking at it. Commented Nov 12, 2019 at 10:59
  • The file is somehow invalid, but what puzzled me is that when I took the sheet into another excel and run the python everything worked just fine... It must be something in that particular excel file, but I still have no idea what... Commented Jan 31, 2020 at 8:47
  • And thanks for your time guys :) Commented Jan 31, 2020 at 8:48

2 Answers 2

3

I'm going to give this an educated guess:

  • The last line (ValueError: Value must be one of {0, 1, 2, [...]) tells us that some value in the Excel file contains an unsupported value.
  • Going up the traceback we see this: [...] openpyxl\styles\alignment.py", line 59, in __init__ which leads me to believe that this is something to do with text alignment.
  • With this in mind, the last-line becomes a bit more interesting: Value must be one of {0, 1, [...] 179, 180}: The possible values range from 0 to 180. So could this possibly be related to text-rotation?

Could it be that the Excel file which works does not have any rotated text, but the file which fails does? If yes, can you try to remove the rotation and try again?

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

Comments

0

rename the file & save it will helps you to load the workbook
or use read_only = True,

wb = load_workbook(filename,read_only = True) 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.