Horizontal alignment lost on cell using conditional formatting

Hello,

We’ve identified an issue with conditional style formatting, as computed by Aspose, when dealing with merged cells.

I’ve attached a small console application describing the issue - the Sheet1:C2 merged cell is configured with both horizontal and vertical alignments as Center. The cell also benefits of a conditional formatting rule. When using Cell.GetConditionalFormattingResult().ConditionalStyle, we see that the horizontal alignment is computed as General instead of Center.

We are using Aspose.Cells version 8.8.0.0.

Any feedback will be highly appreaciated.

Thank you,
Mihai Andrei
Sr Software Engineer
IBM Romania

Hi Mihai,

Thanks for your posting and using Aspose.Cells.

We were able to observe this issue with your sample code and source file using the latest version. Horizontal alignment is shown as General while it should be shown as Center.

We have logged this issue in our database. We will look into it and fix this issue. 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-42538.

C#


string filePath = @“F:\Shak-Data-RW\Downloads\TestFile.xlsx”;


Workbook workbook = new Workbook(filePath);


Worksheet sheet1 = workbook.Worksheets[“Sheet1”];


Cell mergedCell = sheet1.Cells[1, 2];

var conditionalStyle = mergedCell.GetConditionalFormattingResult().ConditionalStyle;


Console.WriteLine(“Conditional Style - horizontal alignment: ‘{0}’”, conditionalStyle.HorizontalAlignment);

Console.WriteLine(“Conditional Style - vertical alignment: ‘{0}’”, conditionalStyle.VerticalAlignment);

Console Output:

Conditional Style - horizontal alignment: 'General’
Conditional Style - vertical alignment: ‘Center’

Hi Mihai,

Thanks for your posting and using Aspose.Cells.

mergedCell.GetConditionalFormattingResult().ConditionalStyle means the result of the conditional formatting and does not include the style of the cell’s self.

And conditional formatting does not support alignment in MS Excel (“Align” setting tab is not visible in conditional formatting)

If you want to get the display style, please use Cell.GetDisplayStyle() method.