@Test void testCreateSheet() { Cell cell0 = mock(Cell.class); Cell cell1 = mock(Cell.class); Row row = mock(Row.class); doReturn(cell0).when(row).createCell(0); doReturn(cell1).when(row).createCell(1); when(sheet.createRow(0)).thenReturn(row); when(workbook.getSheet("test")).thenReturn(null); when(workbook.createSheet("test")).thenReturn(sheet); xlsxWriter.createSheet("test", asList("head1", "head2")); verify(cell0).setCellValue("head1"); verify(cell1).setCellValue("head2"); }
public void createSheet(String name, List<Object> headers) { try { if (name.length() <= MAXIMUM_SHEET_LENGTH) { Sheet sheet = workbook.getSheet(name); if (sheet == null) { sheet = workbook.createSheet(name); writeRow(headers, sheet, 0); } } else { throw new MaximumSheetNameLengthExceededException(name); } } catch (MaximumSheetNameLengthExceededException e) { throw e; } catch (RuntimeException e) { throw new XlsxWriterException(e); } }
XlsxWriter implements AutoCloseable { public void createSheet(String name, List<Object> headers) { try { if (name.length() <= MAXIMUM_SHEET_LENGTH) { Sheet sheet = workbook.getSheet(name); if (sheet == null) { sheet = workbook.createSheet(name); writeRow(headers, sheet, 0); } } else { throw new MaximumSheetNameLengthExceededException(name); } } catch (MaximumSheetNameLengthExceededException e) { throw e; } catch (RuntimeException e) { throw new XlsxWriterException(e); } } }
XlsxWriter implements AutoCloseable { public void createSheet(String name, List<Object> headers) { try { if (name.length() <= MAXIMUM_SHEET_LENGTH) { Sheet sheet = workbook.getSheet(name); if (sheet == null) { sheet = workbook.createSheet(name); writeRow(headers, sheet, 0); } } else { throw new MaximumSheetNameLengthExceededException(name); } } catch (MaximumSheetNameLengthExceededException e) { throw e; } catch (RuntimeException e) { throw new XlsxWriterException(e); } } XlsxWriter(Path target, Workbook workbook); }
XlsxWriter implements AutoCloseable { public void createSheet(String name, List<Object> headers) { try { if (name.length() <= MAXIMUM_SHEET_LENGTH) { Sheet sheet = workbook.getSheet(name); if (sheet == null) { sheet = workbook.createSheet(name); writeRow(headers, sheet, 0); } } else { throw new MaximumSheetNameLengthExceededException(name); } } catch (MaximumSheetNameLengthExceededException e) { throw e; } catch (RuntimeException e) { throw new XlsxWriterException(e); } } XlsxWriter(Path target, Workbook workbook); boolean hasSheet(String name); void createSheet(String name, List<Object> headers); void writeRows(Stream<List<Object>> rows, String sheetName); @Override void close(); }
XlsxWriter implements AutoCloseable { public void createSheet(String name, List<Object> headers) { try { if (name.length() <= MAXIMUM_SHEET_LENGTH) { Sheet sheet = workbook.getSheet(name); if (sheet == null) { sheet = workbook.createSheet(name); writeRow(headers, sheet, 0); } } else { throw new MaximumSheetNameLengthExceededException(name); } } catch (MaximumSheetNameLengthExceededException e) { throw e; } catch (RuntimeException e) { throw new XlsxWriterException(e); } } XlsxWriter(Path target, Workbook workbook); boolean hasSheet(String name); void createSheet(String name, List<Object> headers); void writeRows(Stream<List<Object>> rows, String sheetName); @Override void close();  }