Merged Cells and Borders

Greetings,
I am seeing some inconsistent behavior when it comes to merging cells adjacent to a bordered cell. If you open the attached workbook, you will see what should be two identical objects, a group of merged cells, with another group of bordered merged cells below it.

When I read this workbook with Aspose, what I am seeing are two different results, as it seems like border properties are “shifted” around when cells are merged or borders are added.

In the first example, I created a merged area and then a border. I then merged the cells above it, where it reads “Merged after border”. These are the border properties that I get:

B3,C3: Bottom border
D3: No border
B4: Left border
C4: No border
D4: Top border

In the second example, I created and merged where it reads “Merged before boder”, and then merged a group of cells below it and added the border. These are the border properties that I get:

F3,G3,H3: No border
F4: Top, bottom, left, right border
G4: Top, bottom, right border
H4: Top, bottom, right border

I would expect the values to be consistent regardless of when the cells were merged or when the borders were added. I should note that this worksheet was created in Excel, and then I read it in via Aspose.

I am currently using Aspose.Cells for Java version 2.1.0.1. Thank you for any help that you can provide.

Hi,

Thanks for providing us the template file with details.

Well, it is just MS Excel behavior and not a bug in our version. You can see the user interface regarding the formatting in MS Excel is same and there is no difference. But for the border style of the Cells, there is some difference involved. I try to explain. For borders, when you set TOP border for a cell (e.g A2) in row1, the result regarding UI is the same with setting Bottom border for the previous row cell (A1), is not it? The main reason is for the UI, the top border of A2 is just same with the bottom border of A1. And, furthermore, you cannot make A1 has one kind of BOTTOM border and A2 has another kind of TOP border at the same time, this is impossible. So, it is the MS Excel's behavior for applying border styles on cells and nothing to do with Aspose.Cells for Java.

Thank you.

Amjad Sahi:

For borders, when you set TOP border for a cell (e.g A2) in row1, the result regarding UI is the same with setting Bottom border for the previous row cell (A1), is not it?


That sounds right in theory, I just wasn't sure if that was the desired behavior. I guess I was assuming that when you set a border in a cell, that the border information would be retained in that cell, and not the possibility of it being set in an adjacent one.

Amjad Sahi:

And, furthermore, you cannot make A1 has one kind of BOTTOM border and A2 has another kind of TOP border at the same time, this is impossible.


I suppose that explains why my original assumption was incorrect.

Amjad Sahi:

So, it is the MS Excel's behavior for applying border styles on cells and nothing to do with Aspose.Cells for Java.


Thank you for clearing this up. Your timely response is always appreciated.