问题描述
主要代码如下HSSFWorkbookworkbook=newHSSFWorkbook();HSSFSheetsheet1=workbook.createSheet("sheet1");//创建一个样式HSSFCellStylestyle=workbook.createCellStyle();//设置边框样式style.setBorderTop(HSSFCellStyle.BORDER_THIN);style.setBorderBottom(HSSFCellStyle.BORDER_THIN);style.setBorderLeft(HSSFCellStyle.BORDER_THIN);style.setBorderRight(HSSFCellStyle.BORDER_THIN);//设置边框颜色style.setTopBorderColor(HSSFColor.BLACK.index);style.setBottomBorderColor(HSSFColor.BLACK.index);style.setLeftBorderColor(HSSFColor.BLACK.index);style.setRightBorderColor(HSSFColor.BLACK.index);HSSFRowrow=sheet1.createRow((short)0);HSSFCellcell=row.createCell((short)0);cell.setCellStyle(style);//设置边框row.createCell((short)0).setCellValue("员工号");row.createCell((short)1).setCellValue("员工职位");row.createCell(2).setCellValue("最低薪水");row.createCell(3).setCellValue("最高薪水");for(inti=0;i<joblist.size();i++){row=sheet1.createRow((short)i+1);cell=row.createCell((short)0);cell.setCellStyle(style);//设置边框row.createCell((short)0).setCellValue(joblist.get(i).getJOB_ID());row.createCell((short)1).setCellValue(joblist.get(i).getUSERID());row.createCell((short)2).setCellValue(joblist.get(i).getVENDOR());row.createCell((short)3).setCellValue(joblist.get(i).getUSERNAME());}代码没有出错,但excel边框没有变化,要求有资料的EXCEL边框为黑色。
解决方案
解决方案二:
看你的jar包的版本,多看api。