We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Error While Applying Borders

Hi,


We do have a requirement where-in we apply all types of borders on rows and columns.

While verifying the same, i did notice that when applying borders for a cell that sits below a merged cell the behavior is different.

In the attached spreadsheet documents [SpreadsheetML format] please note:
In Row 3 columns are merged from A to J and we are applying borders from Row 4 to Row 29.
Now, if i do apply border [Top Bottom] on I4 cell, it works fine.
If i do apply border on J4, i do get a Top Border from A4 to J4 and a bottom border only on J4. Typically, i would have expected it only on J4.

(Please do ignore the hidden rows and columns, they are a part of our business logic)

Please do verify the attached spread sheets and let me know if you are looking for any information.

Thanks & Regards,
Richard

Hi,


I have verified your Excel file “Error Border.xml” shows the issue as you stated. I think “Working Border” is your template file, is not it?. We appreciate if you could paste your sample code on how do you set the borders on J4 cell, it will help us to evaluate your issue more accurately to figure it out soon. And, which version of the product you are using?

Thank you.

Hi,

Please download the latest version:
Aspose.Cells
for .NET v7.1.0.1



Please set Workbook.Settings.UpdateAdjacentCellsBorder = false

Please see the following code.

C#


var wb = new Workbook();

wb.Settings.UpdateAdjacentCellsBorder = false;

var ws = wb.Worksheets[0];

Cells cells = ws.Cells;

Cell cell = cells[“J1”];

cell.PutValue(“TestValue”);

Style style = cell.GetStyle();

style.Borders[BorderType.TopBorder].LineStyle = CellBorderType.Thin;

cell.SetStyle(style);

cells.Merge(0, 0, 1, 10);

cell = cells[“J2”];

style = cell.GetStyle();

style.Borders[BorderType.TopBorder].LineStyle = CellBorderType.Thin;

cell.SetStyle(style);

wb.Save(@“D:\FileTemp\dest.xml”);