import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.ss.usermodel.*; import org.apache.poi.openxml4j.exceptions.InvalidFormatException; import java.io.*; public class Sample4_1{ public static void main(String[] args){ Workbook wb = new HSSFWorkbook(); Sheet sheet = wb.createSheet(); sheet.setColumnWidth(1, 4096); Row row1 = sheet.createRow(1); row1.setHeightInPoints(70); Cell cell1_1 = row1.createCell(1); cell1_1.setCellValue("Sample"); CellStyle style = wb.createCellStyle(); style.setBorderTop(CellStyle.BORDER_DASHED); style.setBorderBottom(CellStyle.BORDER_DOUBLE); style.setBorderLeft(CellStyle.BORDER_MEDIUM_DASH_DOT); style.setBorderRight(CellStyle.BORDER_MEDIUM); style.setTopBorderColor(IndexedColors.MAROON.getIndex()); style.setBottomBorderColor(IndexedColors.SKY_BLUE.getIndex()); style.setLeftBorderColor(IndexedColors.ORANGE.getIndex()); style.setRightBorderColor(IndexedColors.BLUE_GREY.getIndex()); cell1_1.setCellStyle(style); FileOutputStream out = null; try{ out = new FileOutputStream("sample4_1.xls"); wb.write(out); }catch(IOException e){ System.out.println(e.toString()); }finally{ try { out.close(); }catch(IOException e){ System.out.println(e.toString()); } } } }