본문 바로가기
프로그래밍 공부/JAVA

JAVA POI setFillBackgroundColor, setFillForegroundColor 안 먹히는 문제

by 꿀떡스 2022. 1. 13.
반응형

#java poi background color 적용 

 

 

 

java poi 를 사용해서 엑셀파일을 만들어왔는데, 

항상 되던 XSSFCellStyle의 setFillBackgroundColor가 먹히지 않는 것이다.

setFillForegroundColor 도 먹히지 않았다.

 

이전 코드는 아래와 같았다.

 

dataStyle = (XSSFCellStyle) workbook.createCellStyle();
titleStyle.setFillBackgroundColor(HSSFColor.GREY_25_PERCENT.index);

 

찾아보니 poi 3.17 부터 변경되었다고 한다.

dataStyle = (XSSFCellStyle) workbook.createCellStyle();
dataStyle.setFillForegroundColor(IndexedColors.YELLOW.getIndex());
dataStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);

 

세번째 setFillPattern(FillPatternType.SOLID_FOREGROUND);를 적용해주니 해결되었다!

 

 

댓글