I've noticed that the same borderside object can appear to have a different style depending on the cell in which you're starting. In the attached spreadsheet...
- wks['C5']).border.bottom.style == 'hair'
- wks['C6']).border.top.style == 'thin'
Why does this happen? If I can understand this, I can account for it in my code, but I don't have my head around how the same physical border could have two different values.
I recognize this is not an openpyxl issue -- this has been how borders have worked since at least Excel 97. I never understood the issue when in Excel, but now that I'm "under the hood" more, I need to better account for it. Is there a recommended way to account for this using openpyxl?
Background, general
I'm a teacher and use openpyxl to read in students' Excel submissions. I'm trying to compare the border between an answer key and the student's submission. What I want to do is something like...
anskey_wks['C5']).border.bottom.style == stu_wks['C5']).border.bottom.style
Instead, I need to add an or statement (or in, any, or something similar) like...
(anskey_wks['C5']).border.bottom.style == stu_wks['C5']).border.bottom.style) or (anskey_wks['C5']).border.bottom.style == stu_wks['C6']).border.top.style)
Background, specific
In this specific situation, the cells started off as follows:
- C5 had a thin top border and a hair bottom border
- C6 has a hair top border and a hair bottom border
The student copied C5 and pasted it throughout the column, pulling the formatting from C5 and applying it to C6, C7, etc. Thus, C6 ended up with a thin top border (just like C5 started with), and visually that's what we see, but "under the hood" C5 retains its hair bottom border.
Thanks for any suggestions or education you can offer!
-David