class HtmlWriter implements DataWriter<HtmlWriteOptions> {

  public void write(Table table, HtmlWriteOptions options) throws IOException {
    ElementCreator elements = options.elementCreator();
    Element html = elements.create("table");
    html.appendChild(header(table.columns(), elements));

    Element tbody = elements.create("tbody");
    html.appendChild(tbody);
    for (int row = 0; row < table.rowCount(); row++) {
      tbody.appendChild(row(row, table, elements, options));
    }

    try (Writer writer = options.destination().createWriter()) {
      writer.write(html.toString());
    }
  }

}