Conversation
|
Thank you for your contribution! For a little more context, what's the motivation for this method instead of requiring the user to explicitly iterate over the range? |
Hello, sorry to reply late, in my case, I need to merge some cells, but when i merged them, there 's something wrong with boders, and i found a same issue #74, so i try to write a function to fix it. |
kevmo314
left a comment
There was a problem hiding this comment.
Thanks, could you add a test and some examples to the README?
| for cell in _range: | ||
| r, c = cell.coordinate | ||
| if r in margin_row or c in margin_col: | ||
| self.set_cell_style(r, c, Style.Style(borders=value._borders)) |
There was a problem hiding this comment.
I'm not sure if this is implemented as users would typically expect. If I set the borders to all four sides and then make a 2x2 range, wouldn't this add borders inside the range as well?
There was a problem hiding this comment.
Yes, it wouldn't add borders to inner cells, but I found there are some more complicated situations that the function may not support, and I also should consider the funtion complexity. I will try a better way.
the 2x2 range example:
from pyexcelerate import Workbook, Style, Font, Alignment
from pyexcelerate.Border import Border
from pyexcelerate.Borders import Borders
data = [[1, 2, 3], [4, 5, 6], [7, 8, 9], ["a", "b", "c"]]
wb = Workbook()
ws = wb.new_sheet("test", data=data)
style = Style(
font=Font(bold=True),
borders=Borders(left=Border(), right=Border(), top=Border(style="double"), bottom=Border(style="double")),
alignment=Alignment('center', 'center')
)
range = ("B2", "C3")
ws.range(*range).merge()
ws.set_range_style(*range, style)
wb.save("test.xlsx")

No description provided.