<%@ page import="org.apache.poi.hssf.usermodel.HSSFSheet"%> <%@ page import="org.apache.poi.hssf.usermodel.HSSFWorkbook"%> <%@ page import="org.apache.poi.hssf.usermodel.HSSFRow"%> <%@ page import="org.apache.poi.hssf.usermodel.HSSFCell"%> <%@ page import="org.apache.poi.hssf.usermodel.HSSFCellStyle"%> <%@ page import="org.apache.poi.hssf.util.HSSFColor"%> <%@ page contentType="application/vnd.ms-excel" %> <%@ page import="java.io.*" %> <%@ page import="java.util.*" %> <% try{ HSSFWorkbook hwb = new HSSFWorkbook(); HSSFSheet sheet = hwb.createSheet("new sheet"); HSSFCellStyle style1 = hwb.createCellStyle(); HSSFCellStyle style2 = hwb.createCellStyle(); HSSFCellStyle style3 = hwb.createCellStyle(); HSSFCellStyle style4 = hwb.createCellStyle(); HSSFCellStyle style = hwb.createCellStyle(); HSSFRow row = sheet.createRow((short) 1); HSSFCell cell = row.createCell((short) 0); cell.setCellValue(1); style.setBorderRight(HSSFCellStyle.BORDER_THIN); style.setRightBorderColor(HSSFColor.BLUE.index); HSSFCell cell4 = row.createCell((short) 1); cell4.setCellValue(2); style1.setBorderTop(HSSFCellStyle.BORDER_MEDIUM_DASHED); style1.setTopBorderColor(HSSFColor.BLACK.index); HSSFCell cell1 = row.createCell((short) 2); cell1.setCellValue(3); style2.setBorderBottom(HSSFCellStyle.BORDER_THIN); style2.setBottomBorderColor(HSSFColor.BLACK.index); HSSFCell cell2 = row.createCell((short) 3); cell2.setCellValue(4); HSSFCell cell3 = row.createCell((short) 4); cell3.setCellValue(5); style3.setBorderBottom(HSSFCellStyle.BORDER_THIN); style3.setBottomBorderColor(HSSFColor.BLACK.index); style4.setBorderBottom(HSSFCellStyle.BORDER_THIN); style4.setBottomBorderColor(HSSFColor.BLACK.index); style.setBorderLeft(HSSFCellStyle.BORDER_THIN); style.setLeftBorderColor(HSSFColor.GREEN.index); cell.setCellStyle(style); cell1.setCellStyle(style1); cell2.setCellStyle(style2); cell3.setCellStyle(style3); cell4.setCellStyle(style4); FileOutputStream fileOut = new FileOutputStream("C:\\excel\\border.xls"); hwb.write(fileOut); fileOut.close(); out.println("Your excel file has been generated"); } catch ( Exception ex ) { } %>