Answer the question
In order to leave comments, you need to log in
How do you know if a cell is merged?
You need to go through the table in certain columns and read the data, but some cells may be merged, so they need to be torn apart and read / overwrite the data.
for cell in column_shablon_cells:
#^^merged_range^^
if (cell in sheet.merged_cells.ranges): # узкое горлышко
unmerge_cells(cell)
print(cell.col_idx)
Answer the question
In order to leave comments, you need to log in
There are many ways to determine if a cell is merged.
For example, cell.CurrentRegion.Count returns the number of individual cells of the cell object - accordingly, for a merged cell, it will return a value greater than one.
If the cell is merged, then the opposite corner can be obtained like this: cell.Offset(1,1).Offset(-1,-1).Address . Knowing the cell nucleus and the address of the opposite corner, it is easy to construct an address for the reverse union by ordinary concatenation.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question