openpyxl merged cells: Formatting issue

烈酒焚心 提交于 2019-12-22 08:43:20

问题


Say I have an xlsx-file and this Excel file has cells A2 and B2 merged. I also select that merged cell and put a border at the top and bottom of the merged cell.

When I do the following:

wb = openpyxl.load_workbook("file.xlsx")
wb.save("resulting file.xlsx")

The result is that only the portion around the merged cell that is in column A now has the border:

Is there a way to prevent this from happening?


回答1:


I believe you are facing Issue#365 , there is generally an issue around styling for merged cells, I believe the above mentioned issues tracks it.

Sadly, I do not see any workaround for this issue, neither is any such workaround mentioned in the issue linked.

Another issue that is more directly related to the one you are facing (it is closed as duplicate of the above mentioned issue) -

Issue#378 - Missing border edges on different cells on open and save existing excel file



来源:https://stackoverflow.com/questions/32254115/openpyxl-merged-cells-formatting-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!