Brian Postow
Brian Postow

Reputation: 12187

openpyxl cell merge with borders?

I'm working on a document with openpyxl, and I have some a named style, it has fill, alignment and borders.

When I try to set the style of a merged cell to this named style, the color,alignment, both work. However, only some of the borders show up.

The current case Im looking at has cells merged in a column. The only borders that are showing up are the top and left.

When I put this same style on a single cell that isn't merged, it has all 4 borders.

I've tried putting the formatting before and after the merge, and it had no effect (which is a good thing I suppose. I'm only formatting the top cell, although when I tried applying the format to all cells before merging, it had no effect.

Upvotes: 2

Views: 3097

Answers (1)

Charlie Clark
Charlie Clark

Reputation: 19507

This is currently not possible in openpyxl <= 2.5 because it requires creating cells simply to hold the styles. Unfortunately, this introduces ambiguity into a worksheet as the cells can be written and read.

openpyxl 2.6 will include support for styling merged cells without ambiguity. See https://bitbucket.org/openpyxl/openpyxl/pull-requests/261 and the associated pull requests for further information.

Upvotes: 1

Related Questions