S
S
studprogrammist2018-06-17 19:11:39
Python
studprogrammist, 2018-06-17 19:11:39

Python, openpyxl module: When writing to an Excel file, how not to remove the outlined borders of a merged cell?

How in Python, using the openpyxl module, when writing a value to an Excel file, do not violate the outlined boundaries of the merged cell?
For example, in the Excel file 'report.xlsx', cells "A1:A2" are merged and a frame (border) is drawn around this merged cell, and cell "C1" is not merged with anyone, but its borders are also outlined.
When writing data to these cells, the border of the "C1" cell remains the same, but the border of the merged cell is violated. Can you please tell me if this "border violation" can be avoided?
Archive with an example: https://yadi.sk/d/LzDQOoca3Y2bim

from openpyxl import Workbook, load_workbook

wb = load_workbook('report.xlsx')
ws = wb.active
ws.title = 'test'

ws['A1'] = "Границы удаляются"

ws['C1'] = "Границы не удаляются"

wb.save('report.xlsx')

Answer the question

In order to leave comments, you need to log in

1 answer(s)
X
Xander017, 2018-06-19
@studprogrammist

Here is a link to an example of working with merged cells.
Styling Merged Cells
I think you will be able to shaman it under your combinations.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question