Hello.
I have found an issue with cell’s borders styles.
I have a book with a table. We performs an analyze borders proccess and found, that library retruns different values of border’s line style for adjacent cells.
public void analyzeBordersTest() throws Exception {
Workbook wb = new Workbook(“D://borders.xlsx”);
Cells cells = wb.getWorksheets().get(0).getCells();
Style topStyle = cells.getCellStyle(4, 15);
Border topBorder = topStyle.getBorders().getByBorderType(BorderType.TOP_BORDER);
Style botStyle = cells.getCellStyle(3, 15);
Border botBorder = topStyle.getBorders().getByBorderType(BorderType.BOTTOM_BORDER);
assertEquals(topBorder.getLineStyle(), botBorder.getLineStyle());
}
Can u help me with this issue?
Best regards. Alexey
Hi Alexey,
Thanks for your posting and using Aspose.Cells.
We have looked into your issue and found error in your code. In the following line, you should use botStyle instead of topStyle
Border botBorder = topStyle.getBorders().getByBorderType(BorderType.BOTTOM_BORDER);
So the correct line will be
Border botBorder = botStyle.getBorders().getByBorderType(BorderType.BOTTOM_BORDER);
Here is a fixed code, changes are highlighted in red. It should fix your issue.
Java
public void analyzeBordersTest() throws Exception {
Workbook wb = new Workbook(“D://borders.xlsx”);
Cells cells = wb.getWorksheets().get(0).getCells();
Style topStyle = cells.getCellStyle(4, 15);
Border topBorder = topStyle.getBorders().getByBorderType(BorderType.TOP_BORDER);
Style botStyle = cells.getCellStyle(3, 15);
Border botBorder = botStyle.getBorders().getByBorderType(BorderType.BOTTOM_BORDER);
assertEquals(topBorder.getLineStyle(), botBorder.getLineStyle());
}