Use XSSFCellStyle.BORDER_MEDIUM
or XSSFBorderFormatting.BORDER_MEDIUM
(both enums refer to the same value):
XSSFCellStyle cellStyle = workbook.createCellStyle();
cellStyle.setBorderTop(XSSFCellStyle.BORDER_MEDIUM);
cellStyle.setBorderRight(XSSFCellStyle.BORDER_MEDIUM);
cellStyle.setBorderBottom(XSSFCellStyle.BORDER_MEDIUM);
cellStyle.setBorderLeft(XSSFCellStyle.BORDER_MEDIUM);
cell.setCellStyle(cellStyle);
Use setBorderColor(XSSFCellBorder.BorderSide.BOTTOM, XSSFColor)
or setBottomBorderColor(XSSFColor)
(equivalent for top, left, right):
XSSFCellStyle cellStyle = workbook.createCellStyle();
XSSFColor color = new XSSFColor(new java.awt.Color(128, 0, 128));
cellStyle.setTopBorderColor(color);
cellStyle.setRightBorderColor(color);
cellStyle.setBottomBorderColor(color);
cellStyle.setLeftBorderColor(color);
cell.setCellStyle(cellStyle);