File file = new File(sExcelPath);
FileInputStream inputStream = new FileInputStream(file);
Workbook workbook = WorkbookFactory.create(inputStream);
org.apache.poi.ss.usermodel.Sheet sheet = workbook.getSheetAt(i);
//设置背景色
CellStyle cellStyle = workbook.createCellStyle();
cellStyle.setFillForegroundColor(IndexedColors.RED.getIndex());
cellStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);
//修改单元格颜色
Row row = sheet.getRow(0);
Cell cell = row.getCell(1);
cell.setCellStyle(cellStyle);
//对修改后的Excel进行保存
FileOutputStream excelFileOutPutStream = new FileOutputStream(file.getAbsolutePath());
workbook.write(excelFileOutPutStream);
excelFileOutPutStream.flush();
excelFileOutPutStream.close();