<%@ page contentType="application;" import="java.io.*,java.text.*" pageEncoding="euc-kr" %><%@ page import = "org.apache.commons.dbutils.* ,java.sql.* ,java.util.* ,java.io.FileInputStream ,org.apache.poi.hssf.usermodel.HSSFCell ,org.apache.poi.hssf.usermodel.HSSFRow ,org.apache.poi.hssf.usermodel.HSSFSheet ,org.apache.poi.hssf.usermodel.HSSFWorkbook ,org.apache.poi.hssf.usermodel.HSSFPalette ,org.apache.poi.hssf.util.HSSFColor ,org.apache.poi.hssf.usermodel.HSSFCellStyle ,org.apache.poi.poifs.filesystem.POIFSFileSystem ,org.apache.poi.ss.util.CellRangeAddress " %><% String type = request.getParameter("t")==null?"color":request.getParameter("t"); short[] colorIdx = { HSSFColor.AQUA.index ,HSSFColor.BLACK.index ,HSSFColor.BLUE.index ,HSSFColor.BLUE_GREY.index ,HSSFColor.BRIGHT_GREEN.index ,HSSFColor.BROWN.index ,HSSFColor.CORAL.index ,HSSFColor.CORNFLOWER_BLUE.index ,HSSFColor.DARK_BLUE.index ,HSSFColor.DARK_GREEN.index ,HSSFColor.DARK_RED.index ,HSSFColor.DARK_TEAL.index ,HSSFColor.DARK_YELLOW.index ,HSSFColor.GOLD.index ,HSSFColor.GREEN.index ,HSSFColor.GREY_25_PERCENT.index ,HSSFColor.GREY_40_PERCENT.index ,HSSFColor.GREY_50_PERCENT.index ,HSSFColor.GREY_80_PERCENT.index ,HSSFColor.INDIGO.index ,HSSFColor.LAVENDER.index ,HSSFColor.LEMON_CHIFFON.index ,HSSFColor.LIGHT_BLUE.index ,HSSFColor.LIGHT_CORNFLOWER_BLUE.index ,HSSFColor.LIGHT_GREEN.index ,HSSFColor.LIGHT_ORANGE.index ,HSSFColor.LIGHT_TURQUOISE.index ,HSSFColor.LIGHT_YELLOW.index ,HSSFColor.LIME.index ,HSSFColor.MAROON.index ,HSSFColor.OLIVE_GREEN.index ,HSSFColor.ORANGE.index ,HSSFColor.ORCHID.index ,HSSFColor.PALE_BLUE.index ,HSSFColor.PINK.index ,HSSFColor.PLUM.index ,HSSFColor.RED.index ,HSSFColor.ROSE.index ,HSSFColor.ROYAL_BLUE.index ,HSSFColor.SEA_GREEN.index ,HSSFColor.SKY_BLUE.index ,HSSFColor.TAN.index ,HSSFColor.TEAL.index ,HSSFColor.TURQUOISE.index ,HSSFColor.VIOLET.index ,HSSFColor.WHITE.index ,HSSFColor.YELLOW.index }; if( type.equals("color") ){ Cookie[] cookieValues = request.getCookies(); HSSFWorkbook wb = new HSSFWorkbook(); HSSFSheet sheet = wb.createSheet("Color Bank"); HSSFRow row = null; HSSFCell cell = null; String temp[] = null; String tmps[] = null; String saveBox = getCookieValue( cookieValues, "saveBox" ); temp = saveBox.split("\\^"); int rowNum = 1; HSSFCellStyle styleBG = wb.createCellStyle(); styleBG.setFillForegroundColor(HSSFColor.GREY_25_PERCENT.index); styleBG.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); for( int i=0; i 6){ if(true){ HSSFPalette palette = wb.getCustomPalette(); palette.setColorAtIndex(colorIdx[++colorIndex], (byte) int2Str(tmps[1]), (byte) int2Str(tmps[2]), (byte) int2Str(tmps[3]) ); HSSFCellStyle style = wb.createCellStyle(); style.setFillForegroundColor(colorIdx[colorIndex]); style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); /******************************/ row = sheet.createRow(rowNum++); cell = row.createCell((short)0); cell.setCellValue(tmps[0].replaceAll("[$]", " ")); cell = row.createCell((short)1); cell.setCellValue(" "); cell.setCellStyle(style); cell = row.createCell((short)2); cell.setCellValue(tmps[1]); cell = row.createCell((short)3); cell.setCellValue(tmps[2]); cell = row.createCell((short)4); cell.setCellValue(tmps[3]); } if(true){ HSSFPalette palette = wb.getCustomPalette(); palette.setColorAtIndex(colorIdx[++colorIndex], (byte) int2Str(tmps[4]), (byte) int2Str(tmps[5]), (byte) int2Str(tmps[6]) ); HSSFCellStyle style = wb.createCellStyle(); style.setFillForegroundColor(colorIdx[colorIndex]); style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); /******************************/ //row = sheet.createRow(rowNum++); cell = row.createCell((short)5); cell.setCellValue(" "); cell.setCellStyle(style); cell = row.createCell((short)6); cell.setCellValue(tmps[4]); cell = row.createCell((short)7); cell.setCellValue(tmps[5]); cell = row.createCell((short)8); cell.setCellValue(tmps[6]); } } if(tmps.length > 9){ if(true){ HSSFPalette palette = wb.getCustomPalette(); palette.setColorAtIndex(colorIdx[++colorIndex], (byte) int2Str(tmps[7]), (byte) int2Str(tmps[8]), (byte) int2Str(tmps[9]) ); HSSFCellStyle style = wb.createCellStyle(); style.setFillForegroundColor(colorIdx[colorIndex]); style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); /******************************/ //row = sheet.createRow(rowNum++); cell = row.createCell((short)9); cell.setCellValue(" "); cell.setCellStyle(style); cell = row.createCell((short)10); cell.setCellValue(tmps[7]); cell = row.createCell((short)11); cell.setCellValue(tmps[8]); cell = row.createCell((short)12); cell.setCellValue(tmps[9]); } } if(tmps.length > 12){ if(true){ HSSFPalette palette = wb.getCustomPalette(); palette.setColorAtIndex(colorIdx[++colorIndex], (byte) int2Str(tmps[10]), (byte) int2Str(tmps[11]), (byte) int2Str(tmps[12]) ); HSSFCellStyle style = wb.createCellStyle(); style.setFillForegroundColor(colorIdx[colorIndex]); style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); /******************************/ //row = sheet.createRow(rowNum++); cell = row.createCell((short)13); cell.setCellValue(" "); cell.setCellStyle(style); cell = row.createCell((short)14); cell.setCellValue(tmps[10]); cell = row.createCell((short)15); cell.setCellValue(tmps[11]); cell = row.createCell((short)16); cell.setCellValue(tmps[12]); } } if(tmps.length > 15){ if(true){ HSSFPalette palette = wb.getCustomPalette(); palette.setColorAtIndex(colorIdx[++colorIndex], (byte) int2Str(tmps[13]), (byte) int2Str(tmps[14]), (byte) int2Str(tmps[15]) ); HSSFCellStyle style = wb.createCellStyle(); style.setFillForegroundColor(colorIdx[colorIndex]); style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); /******************************/ //row = sheet.createRow(rowNum++); cell = row.createCell((short)17); cell.setCellValue(" "); cell.setCellStyle(style); cell = row.createCell((short)18); cell.setCellValue(tmps[13]); cell = row.createCell((short)19); cell.setCellValue(tmps[14]); cell = row.createCell((short)20); cell.setCellValue(tmps[15]); } } /******************************/ //row = sheet.createRow(rowNum++); //row = sheet.createRow(rowNum++); } } response.setHeader("Content-Disposition", "attachment;filename=colorbank.xls;"); out.clear(); out=pageContext.pushBody(); wb.write(response.getOutputStream()); } %><%! public static String getCookieValue( Cookie[] cookieValues, String name ){ for( int i=0; i } return tmp.toString(); } static int int2Str(String i ){ try{ return Integer.parseInt(i); }catch(Exception e){ return 1; } } %>