Class AbstractTableWriterModel

java.lang.Object
org.docx4j.model.table.TableModel
org.docx4j.convert.out.common.writer.AbstractTableWriterModel

public class AbstractTableWriterModel
extends TableModel
There are different ways to represent a table with possibly merged cells.
  • In html, both vertically and horizontally merged cells are represented by one cell only that has a colspan and rowspan attribute. No dummy cells are used.
  • In docx, horizontally merged cells are represented by one cell with a gridSpan attribute; while vertically merged cells are represented as a top cell containing the actual content and a series of dummy cells having a vMerge tag with "continue" attribute.
  • This table is a regular matrix, dummy cells are added for both merge directions.
The algorithm is as follows,
  • When a cell is added, its colspan is set. Even a dummy cell can have a colspan, the same value as its upper has.
  • When a new cell has a colspan greater than 1, the required extra dummy cells are also added
  • When a docx dummy cell is encountered (one with a vMerge continue attribute), the rowspan is incremented in its upper neighbors until a real cell is found.
This model captures: - whether the table layout is fixed or auto (Word usually does auto) - whether conflict resolution is required on cell borders (Word usually does conflict resolution)
Author:
Adam Schmideg, Alberto Zerolo, Jason Harrop
  • Constructor Details

  • Method Details

    • addCell

      public void addCell​(Tc tc, org.w3c.dom.Node content)
      Add a new cell to this table and copy processed content of tc to it.
    • addRow

      protected void addRow​(AbstractTableWriterModelCell cell)
    • build

      public void build​(AbstractWmlConversionContext conversionContext, java.lang.Object node, org.w3c.dom.Node content) throws javax.xml.transform.TransformerException
      Build a table representation from a tbl instance. Remember to set wordMLPackage before using this method!
      Throws:
      javax.xml.transform.TransformerException
    • handleRow

      protected void handleRow​(org.w3c.dom.NodeList cellContents, Tr tr, int r)