Apache POI 之 初学实战篇 (五) --- 边框

初学实战篇

边框设置

Workbook wb = new HSSFWorkbook();
Sheet sheet = wb.createSheet("One");

Row row = sheet.createRow(1);
Cell cell = row.createCell(1);
cell.setCellValue(4);

CellStyle style = wb.createCellStyle();
style.setBorderBottom(CellStyle.BORDER_THIN);
        style.setBottomBorderColor(IndexedColors.BROWN.getIndex());

style.setBorderLeft(CellStyle.BORDER_THIN);
        style.setLeftBorderColor(IndexedColors.GREEN.getIndex());

style.setBorderRight(CellStyle.BORDER_THIN);
        style.setRightBorderColor(IndexedColors.BLUE.getIndex());

        style.setBorderTop(CellStyle.BORDER_MEDIUM_DASHED);
        style.setTopBorderColor(IndexedColors.YELLOW.getIndex());

cell.setCellStyle(style);

FileOutputStream out = new FileOutputStream("wb8.xls");
wb.write(out);
out.close();

你可能感兴趣的:(poi,poi)