### Question:
ExcelMatrixWriter implements IMatrixWriter { @Override public void writeCells(SimpleCell[] cells) { column = 0; sheet.createRow(row); for (SimpleCell sc : cells) { sheet.getRow(row).createCell(column); Cell cell = sheet.getRow(row).getCell(column); cell.setCellValue(sc != null ? sc.getValue(): null); if (sc != null && sc.getCellStyle() != null) { CellStyle style = null; if (stylesCashe.containsKey(sc.getCellStyle())) { style = stylesCashe.get(sc.getCellStyle()); } else { style = workbook.createCellStyle(); style.cloneStyleFrom(sc.getCellStyle()); stylesCashe.put(sc.getCellStyle(), style); } cell.setCellStyle(style); } column++; } row++; } ExcelMatrixWriter(String fileName, boolean useXlsx);  ExcelMatrixWriter(OutputStream outputStream, boolean useXlsx);  ExcelMatrixWriter(String fileName, boolean useXlsx, String sheetName);  ExcelMatrixWriter(OutputStream outputStream, boolean useXlsx, String sheetName); @Override void writeCells(SimpleCell[] cells); @Override void write(String[] strings); @Override void close(); @Override void flush();  }### Answer:
@Test public void testWriteCells() { HSSFWorkbook fakeWorkbook = new HSSFWorkbook(); CellStyle style = fakeWorkbook.createCellStyle(); HSSFColor myColor = HSSFColorPredefined.RED.getColor(); try (ExcelMatrixWriter e = new ExcelMatrixWriter(new FileOutputStream(file), false, "someName")) { SimpleCell[] cells = new SimpleCell[10]; for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { byte[] forString = new byte[32]; new Random().nextBytes(forString); style.setFillForegroundColor(myColor.getIndex()); style.setFillPattern(FillPatternType.SOLID_FOREGROUND); cells[j] = new SimpleCell(new String(forString), style); } e.writeCells(cells); } } catch (IOException ex) { fail(ex.getMessage()); } catch (Exception ex) { fail(ex.getMessage()); } finally { try { fakeWorkbook.close(); } catch (IOException e1) { e1.printStackTrace(); } } try { short bg = WorkbookFactory.create(file).getSheet("someName").getRow(0).getCell(0).getCellStyle() .getFillForegroundColor(); if (bg != HSSFColorPredefined.RED.getIndex()) { fail("wrong color"); } } catch (IOException e1) { fail(e1.getMessage()); } }