PyExcelerate icon indicating copy to clipboard operation
PyExcelerate copied to clipboard

Borders are not appeared on merged cells

Open AAO2014 opened this issue 7 years ago • 3 comments

To make the borders to be visible I have to draw the borders before these cells will be merged. Otherwise, the borders will be drawn partly, only on some merged cells. image

In other words: if I merge some cells, and after that I draw borders around of the range of the cells, not all borders are visible. But if I draw all borders on all the cells and then merge them -- all the borders are visible. image

But, in any cases, thanks for great job! I like your package!

AAO2014 avatar Aug 13 '18 07:08 AAO2014

Thanks for the report, this one might be tricky to fix. Seems like the spec is a bit vague here, but we'll take a look.

kevmo314 avatar Aug 13 '18 21:08 kevmo314

I'm seeing a related border issue so I'm adding a note here instead of opening a new ticket:

I have 4 cells merged as a header and I'm adding Left borders to the left-most column of the 4, and a Right border to the right-most. The middle two columns are untouched style-wise. However, I'm getting Right and Left columns applied to the "outside" two columns like this: extra_borders

The code producing this is: # Set vertical borders bounding cols D through G for 29 rows start = "D1 end = "G1" ws.range(start, end).merge()

                        # Set vertical borders
                        start = "D1"
                        end = "D29"
                        ws.range(start, end).style.borders.left.style = '_'

                        start = "G1"
                        end = "G29"
                        ws.range(start, end).style.borders.right.style = '_'

                        # Now set vertical borders bounding cols H through K 
                        start = "H1
                        end = "K1"
                        ws.range(start, end).merge()

                        # Set vertical borders
                        start = "H1"
                        end = "H29"
                        ws.range(start, end).style.borders.left.style = '_'

                        start = "K1"
                        end = "K29"
                        ws.range(start, end).style.borders.right.style = '_'

If I instead draw borders starting from row 2 (ie change start to D2, G2, H2 and K2 respectively above) then I no longer get the Right border on cols D & H, but still get Left borders on cols G & K. This tells me that the merged cells in row 1 are having an impact. If I remove the code merging those cells, or place it after the code drawing borders, then I get the results in this paragraph (ie only get the extra Left border in cols G&K).

To me, it's a fine solution to obey the rule "Draw borders before merging". I'd still like the borders to be drawn for the ranges defined and not have extra borders added in on G and K. My work-around is to instead never right Right borders, but instead draw Left borders on the next column to the right (H & L). This gives the expected output below

The expected borders are here (notice no right borders on cols D & H, nor left borders on cols G & K) expected_borders

hamx0r avatar Aug 24 '18 15:08 hamx0r

Yeah the spec is kind of vague about how to accurately specify this kind of situation. I'll take a look but it'll require a bit of experimentation to see what kind of configurations Excel spits out, so this may be a bit challenging to solve effectively.

kevmo314 avatar Aug 27 '18 05:08 kevmo314