Free Support Forum - aspose.com

Merge and Background Color issue

Hi,


I am currently facing an issue with reading the background color of the cells after merging them.

Following are two scenarios which are although similar, yielding different results.

1. I create a workbook, worksheet programmatically and assign the background color to A1. I then merged A1:C3. When trying to read the background color of the other cells, we are getting empty value. If I save the workbook and view it in Excel, everything seems to be ok.

2. Now using excel, I do the same above steps of applying background to A1, merging A1:C3. Now when i load the workook programmatically and read the background color of the cells, then I am getting the correct value.

I feel that this issue can also happen with other properties such as Bold, Font Color, etc.

Note : We are using Aspose.Cells = 7.3.1.2

Hi,

Thanks for your posting and using Aspose.Cells for .NET.

We were able to observe the issue using your code. We will investigate this issue and fix it. Once the issue is resolved or we have some other update for you, we will let you know asap.

This issue has been logged as CELLSNET-41510.

Console Output
Color [A=0, R=255, G=0, B=0]
Color [Empty]
Color [Empty]
Color [A=0, R=255, G=0, B=0]
Color [A=0, R=255, G=0, B=0]
Color [A=0, R=255, G=0, B=0]

Hi Shakeel,


Any update on this item?

Thanks.

Hi,

Thanks for your posting and using Aspose.Cells for .NET.

We are afraid, there is no update for you at this moment. However, I have logged your comments. Once, we will have some update for you, we will let you know asap.

Hi,

We have to create all empty cell instances to support your need .

But it will slow down the performance if we create too many cell instances, so please try the following methods to get the cell’s style.

And if A1:C3 is merged in MS Excel,you could not visit Cell B1.

C#


public static Style GetCellStyle(Cells cells, int row, int column)

{

ArrayList list = cells.MergedCells;

for (int i = 0; i < list.Count; i++)

{

CellArea ca = (CellArea)list[i];

if (ca.StartRow <= row

&& ca.EndRow >= row

&& ca.StartColumn <= column

&& ca.EndColumn >= column)

{

return cells[ca.StartRow, ca.StartColumn].GetStyle();

}

}

return cells[row, column].GetStyle(); ;

}