41 번째 행 이후의 제목에서 알 수 있듯이 디버깅 할 때 코드가 잘 작동한다는 것을 알았지 만 제 스타일은 적용되지 않습니다.Apache POI Cellstyle은 41 번째 행 이후에 어떤 이유로 적용되지 않습니다.
내 기능은 다음과 같습니다
private void writeTable(Table table,Row row,Workbook wb){
CellStyle cellStyle = wb.createCellStyle();
if(row.getRowNum() % 2 == 0) {
cellStyle.setFillForegroundColor(IndexedColors.LIGHT_TURQUOISE.getIndex());
cellStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);
cellStyle.setAlignment(CellStyle.ALIGN_CENTER);
cellStyle.setBorderTop(CellStyle.BORDER_THIN);
cellStyle.setWrapText(true);
cellStyle.setTopBorderColor(IndexedColors.GREY_80_PERCENT.getIndex());
cellStyle.setBorderBottom(CellStyle.BORDER_THIN);
cellStyle.setBottomBorderColor(IndexedColors.GREY_80_PERCENT.getIndex());
cellStyle.setBorderRight(CellStyle.BORDER_THIN);
cellStyle.setRightBorderColor(IndexedColors.GREY_80_PERCENT.getIndex());
cellStyle.setBorderLeft(CellStyle.BORDER_THIN);
cellStyle.setLeftBorderColor(IndexedColors.GREY_80_PERCENT.getIndex());
}else{
cellStyle.setFillForegroundColor(IndexedColors.WHITE.getIndex());
cellStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);
cellStyle.setAlignment(CellStyle.ALIGN_CENTER);
cellStyle.setBorderTop(CellStyle.BORDER_THIN);
cellStyle.setWrapText(true);
cellStyle.setTopBorderColor(IndexedColors.GREY_80_PERCENT.getIndex());
cellStyle.setBorderBottom(CellStyle.BORDER_THIN);
cellStyle.setBottomBorderColor(IndexedColors.GREY_80_PERCENT.getIndex());
cellStyle.setBorderRight(CellStyle.BORDER_THIN);
cellStyle.setRightBorderColor(IndexedColors.GREY_80_PERCENT.getIndex());
cellStyle.setBorderLeft(CellStyle.BORDER_THIN);
cellStyle.setLeftBorderColor(IndexedColors.GREY_80_PERCENT.getIndex());
}
Cell cell = row.createCell(0);
cell.setCellValue(Table.index);
cell.setCellStyle(cellStyle);
cell = row.createCell(1);
cell.setCellValue(strCorrecter(Table.Name).isEmpty() ? "-" : strCorrecter(Table.Name));
cell.setCellStyle(cellStyle);
cell = row.createCell(2);
cell.setCellValue(strCorrecter(Table.Surname.toString()).isEmpty() ? "-" : strCorrecter(Table.Surname.toString()));
cell.setCellStyle(cellStyle);
cell = row.createCell(3);
cell.setCellValue("TODO");
cell.setCellStyle(cellStyle);
cell = row.createCell(4);
cell.setCellValue(strCorrecter(Table.Age.toString()).isEmpty() ? "-" : strCorrecter(Table.Age.toString()));
cell.setCellStyle(cellStyle);
cell = row.createCell(5);
cell.setCellValue("TODO");
cell.setCellStyle(cellStyle);
cell =row.createCell(6);
cell.setCellValue("TODO");
cell.setCellStyle(cellStyle);
cell = row.createCell(7);
cell.setCellValue("TODO");
cell.setCellStyle(cellStyle);
cell = row.createCell(8);
cell.setCellValue("TODO");
cell.setCellStyle(cellStyle);
cell = row.createCell(9);
cell.setCellValue("TODO");
cell.setCellStyle(cellStyle);
cell = row.createCell(10);
cell.setCellValue("TODO");
cell.setCellStyle(cellStyle);
cell = row.createCell(11);
cell.setCellValue("TODO");
cell.setCellStyle(cellStyle);
cell = row.createCell(12);
cell.setCellValue("TODO");
cell.setCellStyle(cellStyle);
cell = row.createCell(13);
cell.setCellValue("TODO");
cell.setCellStyle(cellStyle);
cell = row.createCell(14);
cell.setCellValue("TODO");
cell.setCellStyle(cellStyle);
}
그리고 난 다른 문 경우 모든 행 함수의 시작 부분에 통과 것을 알 수있다. 그러나 그들은 엑셀 파일을 볼 때 어떤 속성도없는 것 같습니다./셀 크게
에서 파일 확장자를 변경 (HTTPS ://support.office.com/en-us/article/Excel-specifications-and-limits-1672b34d-7043-467e-8e27-269d656771c3) 통합 문서의 고유 한 셀 서식/셀 스타일의 최대 수를 나타냅니다. 그래서 ** 각 단일 행에 대해 셀 스타일을 만들지 마십시오 **. 내가보기에는 ** 두 개의 다른 셀 스타일 만 필요합니다. 따라서이 두 메서드를 메서드 외부에서 'cellStyle1'과 'cellStyle2'로 만들고 메서드 내에서 두 메서드 중 하나만 사용하십시오. –
어떻게 그 한계를 뛰어 넘을 수 있습니까? 그리고 어떤 이유로 2 가지 스타일을 만들었고 이제는 16 번째 줄에서 끝납니다 : D –
그 한계를 뛰어 넘을 수는 없습니다. 그리고 당신이 제공 한 방법 밖에 ** 두 개의 셀 스타일 **을 만들어야합니다. 하지만 [최소, 완전하고 검증 가능한 예제] (https://stackoverflow.com/help/mcve)를 제공하지 않아서 정말 좋은 대답은 불가능합니다. –