티스토리 뷰
import java.io.FileOutputStream; import org.apache.poi.hssf.usermodel.HSSFCell; import org.apache.poi.hssf.usermodel.HSSFRow; import org.apache.poi.hssf.usermodel.HSSFSheet; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.ss.usermodel.CellStyle; import org.apache.poi.ss.usermodel.IndexedColors; public class Example_POI_Formula { public static void main(String[] args) { HSSFWorkbook wb; HSSFSheet st; HSSFRow row; HSSFCell cell; wb = new HSSFWorkbook(); st = wb.createSheet("Test Sheet"); row = st.createRow(0); cell = row.createCell(0); cell.setCellValue(10); CellStyle style = wb.createCellStyle(); //스타일 생성 style.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.index); //색 설정 style.setFillPattern(CellStyle.SOLID_FOREGROUND); //색 패턴 설정 cell.setCellStyle(style); //스타일 적용 try { FileOutputStream fos = new FileOutputStream("test.xls"); wb.write(fos); } catch(Exception e) {e.printStackTrace();} } } |
댓글