Workbook workbook = null;
workbook = WorkbookFactory.create(inputStream);
Sheet sheet = workbook.getSheetAt(0);
CellStyle cellStyle2 = workbook.createCellStyle();
//設置背景色
cellStyle2.setFillForegroundColor(IndexedColors.RED.getIndex());
cellStyle2.setFillBackgroundColor(IndexedColors.RED.getIndex());
cellStyle2.setFillPattern(FillPatternType.SOLID_FOREGROUND);
//設置字體居中
cellStyle2.setAlignment(HorizontalAlignment.CENTER);
cellStyle2.setVerticalAlignment(VerticalAlignment.CENTER);
sheet.getRow(row).getCell(column).setCellStyle(cellStyle2);
//創建單元格,並賦值
Cell cwyy_cell = sheet.getRow(1).createCell(sheet.getRow(1).getLastCellNum());
cwyy_cell.setCellValue("錯誤原因");
//設置單元格的內容類型,字符串、數字或者其它
sheet.getRow(row).getCell(column).setCellType(CellType.STRING);
//獲取總行數、總列數
int row_num_total = sheet.getLastRowNum();
int column_num_total = sheet.getRow(1).getLastCellNum();