OpenXML SDK border on merged cells applies only to the first cell

When using the OpenXML SDK to apply a border to a merged cell range, the border is displayed only for the first (upper left) cell in the merge range. I have no idea, and it drives me crazy. Using a productivity tool, I can’t find any meaningful difference in what I have and something that works as expected. This is my generated XML for the stylesheet:

<x:borders count="2" xmlns:x="http://schemas.openxmlformats.org/spreadsheetml/2006/main"> <x:border> <x:left /> <x:right /> <x:top /> <x:bottom /> <x:diagonal /> </x:border> <x:border> <x:left /> <x:right /> <x:top /> <x:bottom style="thick"> <x:color auto="1" /> </x:bottom> <x:diagonal /> </x:border> </x:borders> <x:cellXfs xmlns:x="http://schemas.openxmlformats.org/spreadsheetml/2006/main"> <x:xf fontId="0" /> <x:xf fontId="1" fillId="2" applyFont="1" applyFill="1" /> <x:xf borderId="1" applyBorder="1" /> </x:cellXfs> 

I tried everything, applying merge to the border, after, etc.

+5
source share
1 answer

I get it. I got the impression that if you apply the style to the upper left cell in the group of merged cells, then the specified style will be applied to the entire volume. I swear I read some documents that said this, but this is obviously not the case. What worked was that I applied a border style to each cell in the merge range, not just the first one.

It seems strange to me that the way I was originally even acceptable, given that the generated output cannot be reproduced except through the OpenXML SDK.

+5
source

Source: https://habr.com/ru/post/1235326/


All Articles