Wrong border style for merged cell

Hi. I found sometimes API return a wrong border style for merged cell. Check out please following example. Is there is some way to get correct result?

@Test
public void borderTest() throws Exception {
    Workbook wb = new Workbook("D://in.xlsx");
    Cell cell = wb.getWorksheets().get(0).getCells().get("G21");
    int lineStyle = cell.getDisplayStyle().getBorders().getByBorderType(BorderType.LEFT_BORDER).getLineStyle();
    Assert.assertEquals(CellBorderType.THIN, lineStyle);
}

in.zip (16.2 KB)

Best regards. Alexey

@makarovalv,

After an initial test, I am able to observe the issue as you mentioned by using the following sample code with your template file. I found wrong border style returned for merged cell:
e.g
Sample code:

Workbook wb = new Workbook("f:\\files\\in.xlsx"); 
Cell cell = wb.getWorksheets().get(0).getCells().get("G21"); 

if(cell.isMerged()) 
{ 

Range rng = cell.getMergedRange(); 
Iterator<Cell> allCells = rng.iterator(); 
while(allCells.hasNext()) 
{ 
Cell nextCell = allCells.next(); 
int lineStyle = nextCell.getDisplayStyle().getBorders().getByBorderType(BorderType.LEFT_BORDER).getLineStyle(); 
System.out.println("CellBorderType.THIN " + lineStyle); 


} 

I have logged a ticket with an id “CELLSJAVA-42695” for your issue. We will look into it soon.

Once we have an update on it, we will let you know here.

@makarovalv,

This is to inform you that we have fixed your issue now. We will soon provide you the fixed version after performing QA and incorporating other enhancements and fixes.

Thank you. Can you please also check following test on new code:

    @Test
public void borderTest() throws Exception {
    Workbook wb = new Workbook("D://in.xlsx");
    Cells cells = wb.getWorksheets().get(0).getCells();

    Cell cell = cells.get("O36");

    assertEquals(CellBorderType.MEDIUM, cell.getDisplayStyle().getBorders().getByBorderType(BorderType.LEFT_BORDER).getLineStyle());
}

in.zip (889.5 KB)

Best regards. Alexey

@makarovalv,

Thanks for the providing us sample code with template file.

We will try to include the fix for medium border type as well in the upcoming release. If the fix for this issue is not included in the upcoming release, we will add a new ticket for it.

The issues you have found earlier (filed as CELLSJAVA-42695) have been fixed in Aspose.Cells for Java 18.8. You can also get the latest Aspose.Cells for Java version from Maven repos. with simple configurations. Please see the document for your reference: Installation|Documentation

This message was posted using BugNotificationTool from Downloads module by Amjad_Sahi

@makarovalv,

I also tested your recent scenario/case using our latest version/fix: Aspose.Cells for Java v18.8 (please try it), it works fine.

Hi. Thanks for update, but new version contains very critical bug. After reading a cell style, gray borders appears for it.

@Test
public void borderTest() throws Exception {
    Workbook wb = new Workbook("D://in.xlsx");

    Cells cells = wb.getWorksheets().get(0).getCells();
    for (int row = 0; row <= cells.getMaxDataRow(); row++) {
        for (int column = 0; column <= cells.getMaxDataColumn(); column++) {
            Cell cell = cells.get(row, column);
            Style style = cell.getDisplayStyle();
            BorderCollection borders = style.getBorders();
            System.out.println(
                    cell.getName() + ": " +
                            borders.getByBorderType(BorderType.LEFT_BORDER).getLineStyle() + "/" +
                            borders.getByBorderType(BorderType.TOP_BORDER).getLineStyle() + "/" +
                            borders.getByBorderType(BorderType.RIGHT_BORDER).getLineStyle() + "/" +
                            borders.getByBorderType(BorderType.BOTTOM_BORDER).getLineStyle()
            );
        }
    }

    wb.save("D://out.xlsx");
}

in and out.zip (32.9 KB)

Best regards. Alexey

@makarovalv,

Thanks for the sample code and template file.

After an initial test, I am able to observe the issue as you mentioned by using your sample code with your template file. After reading a cell style, gray borders appear in the worksheet for it. I have logged a ticket with an id “CELLSJAVA-42702” for your issue. We will look into it soon.

Once we have an update on it, we will let you know here.

@makarovalv,

This is to inform you that we have fixed your issue CELLSJAVA-42702 now. We will soon provide you the fixed version after performing QA and incorporating other enhancements and fixes.

@makarovalv,

Please try our latest version/fix: Aspose.Cells for Java v18.8.2 (attached)

Your issue should be fixed in it.

Let us know your feedback.
fix18.8.2.zip (6.3 MB)

Hi. Thank you for update, but bug with borders is still presented.

    @Test
public void borderTest() throws Exception {
    Workbook wb = new Workbook("D://in.xlsx");

    Range range = wb.getWorksheets().get(0).getCells().get("BL28").getMergedRange();

    Iterator<Cell> cells = range.iterator();
    while (cells.hasNext()) {
        Cell cell = cells.next();

        System.out.println(cell.getName() + " " +cell.getDisplayStyle().getBorders().getByBorderType(BorderType.BOTTOM_BORDER).getLineStyle());
    }

}

in.zip (730.7 KB)

Also bottom border for cell “J28” defines incorrect too.

@makarovalv,

Thanks for the sample code with template file.

After an initial test, I am able to observe the issue as you mentioned by using your sample code with your new attached file. I found wrong bottom border style returned for merged cells (e.g BL28 and J28).

I have logged a ticket with an id “CELLSJAVA-42709” for your issue. We will look into it soon.

Once we have an update on it, we will let you know here.

@makarovalv,

This is to inform you that we have fixed your issue (logged earlier as “CELLSJAVA-42709”) now. We will soon provide you the fixed version after performing QA and incorporating other enhancements and fixes.

@makarovalv,

Please try our latest version/fix (attached): Aspose.Cells for Java v18.8.3

Your issue “CELLSJAVA-42709” should be fixed in it.

Let us know your feedback.

Aspose.Cells for Java v18.8.3.zip (6.3 MB)

Hi. Thanks for update. It is looks like all is correct. Thank you very much!

Best regards. Alexey

@makarovalv,

Good to know that your issue is sorted out by the new fix/version. Feel free to contact us any time if you need further help or have some other issue or queries, we will be happy to assist you soon.

The issues you have found earlier (filed as CELLSJAVA-42709,CELLSJAVA-42702) have been fixed in Aspose.Cells for Java 18.9. You can also get the latest Aspose.Cells for Java version from Maven repos. with simple configurations. Please see the document for your reference: Installation|Documentation

This message was posted using BugNotificationTool from Downloads module by Amjad_Sahi