1 2 17 18 19 package org.apache.poi.hssf.usermodel.examples; 20 21 import org.apache.poi.hssf.usermodel.*; 22 import org.apache.poi.hssf.util.HSSFColor; 23 24 import java.io.FileOutputStream ; 25 import java.io.IOException ; 26 27 32 public class Borders 33 { 34 public static void main(String [] args) 35 throws IOException 36 { 37 HSSFWorkbook wb = new HSSFWorkbook(); 38 HSSFSheet sheet = wb.createSheet("new sheet"); 39 40 HSSFRow row = sheet.createRow((short) 1); 42 43 HSSFCell cell = row.createCell((short) 1); 45 cell.setCellValue(4); 46 47 HSSFCellStyle style = wb.createCellStyle(); 49 style.setBorderBottom(HSSFCellStyle.BORDER_THIN); 50 style.setBottomBorderColor(HSSFColor.BLACK.index); 51 style.setBorderLeft(HSSFCellStyle.BORDER_THIN); 52 style.setLeftBorderColor(HSSFColor.GREEN.index); 53 style.setBorderRight(HSSFCellStyle.BORDER_THIN); 54 style.setRightBorderColor(HSSFColor.BLUE.index); 55 style.setBorderTop(HSSFCellStyle.BORDER_MEDIUM_DASHED); 56 style.setTopBorderColor(HSSFColor.ORANGE.index); 57 cell.setCellStyle(style); 58 59 FileOutputStream fileOut = new FileOutputStream ("workbook.xls"); 61 wb.write(fileOut); 62 fileOut.close(); 63 } 64 } 65 | Popular Tags |