2017-03-16 106 views

回答

0

//創建一個單元格並在其中放入一個值。

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

//將邊界四周的單元格樣式化。

CellStyle style = wb.createCellStyle(); 
    style.setBorderBottom(CellStyle.BORDER_THIN); 
    style.setBottomBorderColor(IndexedColors.BLACK.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.BLACK.getIndex()); 
    cell.setCellStyle(style); 

如果需要的話迭代。

+0

在合併單元格中沒有反映。 – tango

+0

首先,您必須在要合併的所有單元上應用邊界,而不是合併它。有用' –