Borders not found

Attached is a spreadsheet. Here is the code to read it:

class Program

{

private static readonly Workbook wb = new Workbook();

static void Main(string[] args)

{

wb.Open(@"c:\temp\don.xls");

Worksheet ws = wb.Worksheets[0];

Cell c = ws.Cells[17, 1];

Border b = c.Style.Borders[BorderType.RightBorder];

}

The right border is not being found even though it appears in Excel and the properties.

Thanks for providing us the template file and code.



Well, Cell B18 does not have its right border actually, so the border 's line type would be none.

But we have found ab issue. If we try to get the right border of the C18 cell, it is not found.

Sample code:

Workbook wb = new Workbook();

wb.Open(@“e:\test\don.xls”);

Worksheet ws = wb.Worksheets[0];

Aspose.Cells.Cell c = ws.Cells[17, 2];

Border b = c.Style.Borders[BorderType.RightBorder];

MessageBox.Show(b.LineStyle.ToString()); //None.



It looks very strange for your file. We need to investigate further whether it
is a bug in the product or not. Anyways, we have added your issue into
our issue tracking system with an issue id: CELLSNET-13668. We will update you about the issue soon.



Thank you.

Hi,

After further investigation, we come to know that It’s not a bug. The border is actually the left border of the cell “D18”.

See following code below.

Sample code:



Workbook workbook = new Workbook();

workbook.Open(@“F:\FileTemp\don.xls”);
Worksheet ws = workbook.Worksheets[0];
Aspose.Cells.Cell c = ws.Cells[17, 2];
Border b = c.Style.Borders[BorderType.RightBorder];


Console.WriteLine(b.LineStyle);

c = ws.Cells[17, 3];
Console.WriteLine(c.GetStyle().Borders[BorderType.LeftBorder].LineStyle);



We think that The file is not generated by MS Excel. If you set the left border of the cell in MS Excel, MS Excel will change the right border of the adjacent cell. Aspose.Cells do not support to change the style setting of adjacent cells if you call Cell.SetStyle method.


So, please use Cell. SetStyle(Style style, true) method if you want to change them too.



Thank you.

Guys,

I will investigate further but a couple of comments:

  • I do not know the origins of the Excel file but it was probably done by hand, not programatically. It may be an old version of Excel but I think it was done by a human in Excel.
  • If you open the file in Excel (I am using Excel 2010), right-click, format cells, border tab, it shows the right border in the border tab.

Like you, I am a programmer. I think this appears to be a bug albeit a very subtle one. I can probably code around it but I think you should give it more focus because I do not believe that Aspose.Cells is replicating how Excel works.

Alan

Hi,

We will auto detect the borders of adjacent cells in
getting the cell style. It will work as MS Excel.


We have added this feature request to our issue tracking system with an issue id: CELLSNET-13733.


We will provide the supported version soon.

Thank you.

Hi Alan,

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for considering Aspose.

We have supported your requested feature.

Thank You & Best Regards,

Thanks guys. This should help eliminate confusion for developers.

Alan

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


This message was posted using Notification2Forum from Downloads module by aspose.notifier.