Overlapping styles

Hello guys:

What’s wrong: I thought when styles are applied in succession to a cell, the previous styles are preserved. But that doesn’t seem to be the case in this particular example. If you run the following function you’ll see that applying the left border affected the alignment of cell A1. On the other hand, if you change the sample and add a right border, the right border won’t affect the alignment, i.e. it works as I expected. I tested the function using version 7.7.0 of aspose cells .Net.

Code:
private static void TestStylesOverlapping()
{
string path = @“C:\temp\spreadsheets”;
string fileName = path + “test_styles_overlapping.xlsx”;
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];

// Center A1

Cell cell = worksheet.Cells[0, 0];
cell.Value = “A1”;
Style style = cell.GetStyle();
style.HorizontalAlignment = TextAlignmentType.Center;
StyleFlag styleFlag = new StyleFlag();
styleFlag.HorizontalAlignment = true;
cell.SetStyle(style, styleFlag);


// Draw bottom border to range A1:C1

Range range = worksheet.Cells.CreateRange(“A1:C1”);
style = new Style();
Border border = style.Borders[BorderType.BottomBorder];
border.LineStyle = CellBorderType.Thick;
border.Color = Color.Red;
styleFlag = new StyleFlag();
styleFlag.BottomBorder = true;
range.ApplyStyle(style, styleFlag);


// Draw the left border to range A1:A10

range = worksheet.Cells.CreateRange(“A1:A10”);
style = new Style();
border = style.Borders[BorderType.LeftBorder];
border.LineStyle = CellBorderType.Thick;
border.Color = Color.Green;
styleFlag = new StyleFlag();
styleFlag.LeftBorder = true;
range.ApplyStyle(style, styleFlag);

// Save the workbook
workbook.Save(fileName, FileFormatType.Xlsx);
Process.Start(fileName);

}

Hi Costa,

Thanks for your posting and using Aspose.Cells.

We were able to observe this issue using the latest version with your given code. When the left border is applied on the cells, the alignment of the cell A1 changes. But when right border is applied on the cells, the alignment of the cell A1 remains same. We have logged this issue in our database for investigation. We will look into it and update you. Once, there is some fix or any other update for you, we will let you know asap.

This issue has been logged as CELLSNET-42239.

Hi,

Thanks for using Aspose.Cells for .NET.

We have fixed this issue.

Please download and try this fix: Aspose.Cells for .NET v7.7.0.2 and let us know your feedback.

The issues you have found earlier (filed as CELLSNET-42239) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.