Weird pseudo-merged cells

47 views
Skip to first unread message

Peter Holzer

unread,
Feb 16, 2025, 6:03:15 AMFeb 16
to openpyxl-users
(this is an excerpt from a larger file. Only one worksheet and all the data has been deleted)

It contains 3 "real" mergeCells: A4:A6, B4:C6, D4:F5.

But it also contains three ranges (G4:L4, G5:I5, J5:L5) which behave similarly:

  • They look like merged cells in Excel and LibreOffice Calc
  • LibreOffice the ranges are treated as units when you click them (outline around the whole range, all the columns are marked, you edit the same value, no matter where you clicked)
but not completely:
  • In Excel, the cells of the ranges are treated as separate when you click into them (outline around individual cells, you can edit each cell individually)
  • Also in Excel, when I enter a value in one of the fields, the text is now centered over the remaining fields (e.g. if I enter something into K4, the text "d a v o n" is centered over G4:J4). So clearly Excel knows that these cells are somehow connected.
What is going on here and how can I detect this in openpyxl? I want my script to detect that "d a v o n" spans columns G to L and that "Arbeiter" and "Angestellte" span G to I and J to L respectively.

Peter Holzer

unread,
Feb 17, 2025, 7:13:32 AMFeb 17
to openpyx...@googlegroups.com
Found it:

These cells are formatted with alignment.horizontal='centerContinuous'.
Apparently the rule is that if a cell is empty and aligned
centerContinuous and the cell to the left is also aligned
centerContinuous, then this cell is an extension of the cell to the
left.
> --
> You received this message because you are subscribed to a topic in the Google Groups "openpyxl-users" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/openpyxl-users/M-L-cHC7itI/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to openpyxl-user...@googlegroups.com.
> To view this discussion, visit https://groups.google.com/d/msgid/openpyxl-users/170666fc-1648-4f4e-9c38-c09e4d852043n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages