@Test public void should_generate_table_without_header() { initDefaultTable(); configureExport(new ExportConf.Builder("csv").header(false).build()); processExport(new CsvExport()); String firstLine = new Scanner(new String(baos.toByteArray())).nextLine(); assertThat(firstLine).doesNotContain("Id;FirstName;LastName;City;Mail"); assertThat(new String(baos.toByteArray()).split("\n")).hasSize(Mock.persons.size()); }
@Override public void processExport(OutputStream output) { StringBuilder buffer = new StringBuilder(); if (exportConf.getIncludeHeader()) { for (HtmlRow row : table.getHeadRows()) { for (HtmlColumn column : row.getColumns(ReservedFormat.ALL, ReservedFormat.CSV)) { buffer.append(column.getContent()).append(SEPARATOR_CHAR); } buffer.append("\n"); } } for (HtmlRow row : table.getBodyRows()) { for (HtmlColumn column : row.getColumns(ReservedFormat.ALL, ReservedFormat.CSV)) { buffer.append(column.getContent()).append(SEPARATOR_CHAR); } buffer.append("\n"); } try { output.write(buffer.toString().getBytes()); } catch (IOException e) { StringBuilder sb = new StringBuilder("Something went wrong during the CSV generation of the table '"); sb.append(table.getOriginalId()); sb.append("' and with the following export configuration: "); sb.append(exportConf.toString()); throw new DandelionException(sb.toString(), e); } }
CsvExport implements DatatablesExport { @Override public void processExport(OutputStream output) { StringBuilder buffer = new StringBuilder(); if (exportConf.getIncludeHeader()) { for (HtmlRow row : table.getHeadRows()) { for (HtmlColumn column : row.getColumns(ReservedFormat.ALL, ReservedFormat.CSV)) { buffer.append(column.getContent()).append(SEPARATOR_CHAR); } buffer.append("\n"); } } for (HtmlRow row : table.getBodyRows()) { for (HtmlColumn column : row.getColumns(ReservedFormat.ALL, ReservedFormat.CSV)) { buffer.append(column.getContent()).append(SEPARATOR_CHAR); } buffer.append("\n"); } try { output.write(buffer.toString().getBytes()); } catch (IOException e) { StringBuilder sb = new StringBuilder("Something went wrong during the CSV generation of the table '"); sb.append(table.getOriginalId()); sb.append("' and with the following export configuration: "); sb.append(exportConf.toString()); throw new DandelionException(sb.toString(), e); } } }
CsvExport implements DatatablesExport { @Override public void processExport(OutputStream output) { StringBuilder buffer = new StringBuilder(); if (exportConf.getIncludeHeader()) { for (HtmlRow row : table.getHeadRows()) { for (HtmlColumn column : row.getColumns(ReservedFormat.ALL, ReservedFormat.CSV)) { buffer.append(column.getContent()).append(SEPARATOR_CHAR); } buffer.append("\n"); } } for (HtmlRow row : table.getBodyRows()) { for (HtmlColumn column : row.getColumns(ReservedFormat.ALL, ReservedFormat.CSV)) { buffer.append(column.getContent()).append(SEPARATOR_CHAR); } buffer.append("\n"); } try { output.write(buffer.toString().getBytes()); } catch (IOException e) { StringBuilder sb = new StringBuilder("Something went wrong during the CSV generation of the table '"); sb.append(table.getOriginalId()); sb.append("' and with the following export configuration: "); sb.append(exportConf.toString()); throw new DandelionException(sb.toString(), e); } }  }
CsvExport implements DatatablesExport { @Override public void processExport(OutputStream output) { StringBuilder buffer = new StringBuilder(); if (exportConf.getIncludeHeader()) { for (HtmlRow row : table.getHeadRows()) { for (HtmlColumn column : row.getColumns(ReservedFormat.ALL, ReservedFormat.CSV)) { buffer.append(column.getContent()).append(SEPARATOR_CHAR); } buffer.append("\n"); } } for (HtmlRow row : table.getBodyRows()) { for (HtmlColumn column : row.getColumns(ReservedFormat.ALL, ReservedFormat.CSV)) { buffer.append(column.getContent()).append(SEPARATOR_CHAR); } buffer.append("\n"); } try { output.write(buffer.toString().getBytes()); } catch (IOException e) { StringBuilder sb = new StringBuilder("Something went wrong during the CSV generation of the table '"); sb.append(table.getOriginalId()); sb.append("' and with the following export configuration: "); sb.append(exportConf.toString()); throw new DandelionException(sb.toString(), e); } }  @Override void initExport(HtmlTable table); @Override void processExport(OutputStream output); }
CsvExport implements DatatablesExport { @Override public void processExport(OutputStream output) { StringBuilder buffer = new StringBuilder(); if (exportConf.getIncludeHeader()) { for (HtmlRow row : table.getHeadRows()) { for (HtmlColumn column : row.getColumns(ReservedFormat.ALL, ReservedFormat.CSV)) { buffer.append(column.getContent()).append(SEPARATOR_CHAR); } buffer.append("\n"); } } for (HtmlRow row : table.getBodyRows()) { for (HtmlColumn column : row.getColumns(ReservedFormat.ALL, ReservedFormat.CSV)) { buffer.append(column.getContent()).append(SEPARATOR_CHAR); } buffer.append("\n"); } try { output.write(buffer.toString().getBytes()); } catch (IOException e) { StringBuilder sb = new StringBuilder("Something went wrong during the CSV generation of the table '"); sb.append(table.getOriginalId()); sb.append("' and with the following export configuration: "); sb.append(exportConf.toString()); throw new DandelionException(sb.toString(), e); } }  @Override void initExport(HtmlTable table); @Override void processExport(OutputStream output);  }