2016-09-29 22 views

回答

1
  1. 创建要样式:

     HSSFCellStyle my_style = my_workbook.createCellStyle();  
    
         /* Draw a thin left border */ 
         my_style.setBorderLeft(HSSFCellStyle.BORDER_THIN);/* Add medium right border */ 
         my_style.setBorderRight(HSSFCellStyle.BORDER_MEDIUM);/* Add dashed top border */ 
         my_style.setBorderTop(HSSFCellStyle.BORDER_DASHED); /* Add dotted bottom border */ 
         my_style.setBorderBottom(HSSFCellStyle.BORDER_DOTTED); 
    
  2. 创建一个行:

    /*Create a row */ 
        Row row = my_sheet.createRow(0); 
    
  3. 添加细胞行成你想要的边框样式:

    /*Now add cells to the row*/ 
        Cell cell = row.createCell(0); 
        cell.setCellValue("Add Border Example - 1 "); 
        /*Now add style to your cell 
        cell.setCellStyle(my_style); 
    
  4. 重复为之前创建的行创建单元格的过程