🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
```java //创建样式对象 CellStyle cellStyle = workbook.createCellStyle(); //设置单元格边框上/右/下/左的边框样式 cellStyle.setBorderTop(BorderStyle.MEDIUM_DASHED); cellStyle.setBorderRight(BorderStyle.MEDIUM_DASHED); cellStyle.setBorderBottom(BorderStyle.MEDIUM_DASHED); cellStyle.setBorderLeft(BorderStyle.MEDIUM_DASHED); SXSSFRow row = sheet.createRow(i + 1); SXSSFCell cell = row.createCell(0); //将样式用到单元格中 cell.setCellStyle(cellStyle); ``` 边框效果如下: ![](https://img.kancloud.cn/a8/93/a893b4c355b33c5fdc7cb9ceea45c589_1637x267.png)