Здесь ниже я публикую две функции из моего Java-класса. Когда я пытаюсь установить стиль ячейки, он не отражается в файле Excel. Я искал об этом в Интернете, но везде они давали код для придания стиля при создании самой ячейки/строки.
Код: Выделить всё
public static CellStyle getNewCellStyle(){
CellStyle style = myWorkBook.createCellStyle();
style.setFillBackgroundColor(IndexedColors.GREEN.getIndex());
style.setFillPattern(CellStyle.ALIGN_FILL);
return style;
}
public static void chCaseNumberColumnValidation(Cell cell){
String cellData = getCellDataValue(cell);
if(cellData.length() == 10){
if(cellData.equals("BLANK") || cellData.trim().length() == 0){
System.out.println("BLANK CELL: " + cell.getRowIndex() + "," + cell.getColumnIndex());
}
if(cellData.charAt(0) != '5'){
System.out.println("DON't START WITH 5: " + cell.getRowIndex() + "," + cell.getColumnIndex());
cell.setCellStyle(getNewCellStyle());
}
}
else{
System.out.println("****INVALID SIZE " + cell.getRowIndex() + "," + cell.getColumnIndex());
}
}
Подробнее здесь: https://stackoverflow.com/questions/350 ... oi-library
Мобильная версия