1、首先,利用Eclipse新建普通的Java工程,以供测试使用
2、在Java工程中新建【lib】文件夹,向文件夹导入我们所需要的Jar包
3、创建测试类,输入如图所示的代码
4、我们需要创建CellStyle对象(单元格样式),在其中添加我们所需要的边框设置代码:CellStyle style = wb.createCellStyle();
5、通过CellStyle的【setBorderBottom】、【setBorderLeft】、【setBorderRight】、【setBorderTop】方法来设置下、左、右、上的边框样式
6、通过BorderStyle的静态属性,来设置边框的样式比如:BorderStyle.THIN
7、通过CellStyle的【setBottomBorderColor】【setLeftBorderColor】【setRightBord髫潋啜缅erColor】【setTopBorderColor】方法设置下、左、右、上边框颜色