-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add set_range_style by a simple way #81
base: dev
Are you sure you want to change the base?
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.