
excel
你跑下下面的代码试下吧:public Test
excel(){ create
excelFile(); } private void create
excelFile() { HSSFWorkbook hwb = new HSSFWorkbook(); HSSFSheet sheet = hwb.createSheet(test sheet); //创建一个样式 HSSFCellStyle style = hwb.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); for(int j=0;j5;j++){ HSSFRow row = sheet.createRow(j); for(int i=0;i10;i++){ HSSFCell cell = row.createCell(i); cell.s
etcellStyle(style); cell.s
etcellValue(j+*+i); } } File file = new File(./test.xls); try { FileOutputStream fos = new FileOutputStream(file); hwb.write(fos); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }