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

Free Support Forum - aspose.com

Adding border with indentation to cells is not working

Cell cell = cells.get(position);

Style style = cell.getStyle();
style.setBorder(BorderType.RIGHT_BORDER, CellBorderType.THICK, Color.getBlack());

The problem is, the border and indentation does not apply to a to column at a time.


Thanks for the sample code segment.

I have tested your scenario/ case a bit. I used the following sample code and it works fine. The right border and indentation are applied fine. I have also attached the output file for your reference. It looks like your text is more than cell’s width, so the right border might not be displayed. I suggest you to kindly extend the width of the column appropriately as you can see in my code, I have applied auto-fit column operation so the cell’s width should be extended accordingly based on the text length.
Sample code:

// Instantiating a Workbook object
Workbook workbook = new Workbook();

// Accessing the added worksheet in the Excel file
int sheetIndex = workbook.getWorksheets().add();
Worksheet worksheet = workbook.getWorksheets().get(sheetIndex);
Cells cells = worksheet.getCells();

// Adding the current system date to “A1” cell
Cell cell = cells.get(“A1”);
Style style = cell.getStyle();

// Adding some value to the “A1” cell
cell.setValue(“Visit Aspose!”);

// Setting the vertical alignment of the text in a cell
Style style1 = cell.getStyle();
style1.setBorder(BorderType.RIGHT_BORDER, CellBorderType.THICK, Color.getBlack());

// Saved style


// Saving the modified Excel file in default format

If you still find any issue, kindly do paste your complete JAVA program (runnable) with template file to reproduce the issue on our end, we will check it soon.

Thank you.