Package org.docx4j.wml

Examples of org.docx4j.wml.Tbl


      int cols = 3;
      int cellWidthTwips = new Double(
                    Math.floor( (writableWidthTwips/cols ))
                      ).intValue();
     
      Tbl tbl = TblFactory.createTable(3, 3, cellWidthTwips);
      mdp.addObject(tbl);
     
   
       // Pretty print the main document part
    System.out.println(
View Full Code Here


   
    MainDocumentPart mdp = wordMLPackage.getMainDocumentPart();
   
    org.docx4j.wml.ObjectFactory wmlObjectFactory = new org.docx4j.wml.ObjectFactory();

    Tbl tbl = wmlObjectFactory.createTbl();
    JAXBElement<org.docx4j.wml.Tbl> tblWrapped = wmlObjectFactory.createCTFtnEdnTbl(tbl);
        // Create object for tr
        Tr tr = wmlObjectFactory.createTr();
        tbl.getContent().add( tr);
            // Create object for tc (wrapped in JAXBElement)
            Tc tc = wmlObjectFactory.createTc();
            JAXBElement<org.docx4j.wml.Tc> tcWrapped = wmlObjectFactory.createTrTc(tc);
            tr.getContent().add( tcWrapped);    
   
View Full Code Here

  /**
   * Build a table representation from a <var>tbl</var> instance.
   * Remember to set wordMLPackage before using this method!
   */
  public void build(AbstractWmlConversionContext conversionContext, Object node, Node content) throws TransformerException {
    Tbl tbl = null;
    try {
      tbl = (Tbl)node;
    } catch (ClassCastException e) {
      throw new TransformerException("Node is not of the type Tbl it is " + node.getClass().getName());
    }

    if (tbl.getTblPr()!=null
        && tbl.getTblPr().getTblStyle()!=null) {
      styleId = tbl.getTblPr().getTblStyle().getVal();     
    }
   
   
    this.tblGrid = tbl.getTblGrid();
   
    this.tblPr = tbl.getTblPr();
   
    PropertyResolver pr = conversionContext.getPropertyResolver();
     
    effectiveTableStyle = pr.getEffectiveTableStyle(tbl.getTblPr() );
//      if (tblPr!=null
//          && tblPr.getTblW()!=null) {
//        if (tblPr.getTblW().getType()!=null
//            && (tblPr.getTblW().getType().equals("auto")
//                || tblPr.getTblW().getType().equals("nil") )) {
View Full Code Here

        NodeIterator tables) {
     
      // The only way we seem to be able to make rules which
      // apply to all the cells in a particular table
     
      Tbl tbl;
      StringBuffer result = new StringBuffer();   
     
    //DTMNodeProxy n = (DTMNodeProxy)tables.nextNode();
      Element n = (Element)tables.nextNode();
    if (n==null) {
View Full Code Here

      int cols = 3;
      int cellWidthTwips = new Double(
                    Math.floor( (writableWidthTwips/cols ))
                      ).intValue();
     
      Tbl tbl = TblFactory.createTable(3, 3, cellWidthTwips);
      mdp.addObject(tbl);
     
   
       // Pretty print the main document part
    System.out.println(
View Full Code Here

public class TblFactory {
 
 
  public static Tbl createTable(int rows, int cols, int cellWidthTwips) {
   
    Tbl tbl = Context.getWmlObjectFactory().createTbl();   
   
    // w:tblPr
    String strTblPr =  "<w:tblPr " + Namespaces.W_NAMESPACE_DECLARATION + ">"
      + "<w:tblStyle w:val=\"TableGrid\"/>"
      +   "<w:tblW w:w=\"0\" w:type=\"auto\"/>"
      +   "<w:tblLook w:val=\"04A0\"/>"
      + "</w:tblPr>";
    TblPr tblPr = null;
    try {
      tblPr = (TblPr)XmlUtils.unmarshalString(strTblPr);
    } catch (JAXBException e) {
      // Shouldn't happen
      e.printStackTrace();
    }
    tbl.setTblPr(tblPr);
   
    // <w:tblGrid><w:gridCol w:w="4788"/>   
    TblGrid tblGrid = Context.getWmlObjectFactory().createTblGrid();
    tbl.setTblGrid(tblGrid);
    // Add required <w:gridCol w:w="4788"/>
    for (int i=1 ; i<=cols; i++) {
      TblGridCol gridCol = Context.getWmlObjectFactory().createTblGridCol();
      gridCol.setW(BigInteger.valueOf(cellWidthTwips));
      tblGrid.getGridCol().add(gridCol);
    }
       
    // Now the rows
    for (int j=1 ; j<=rows; j++) {
      Tr tr = Context.getWmlObjectFactory().createTr();
      tbl.getEGContentRowContent().add(tr);
     
      // The cells
      for (int i=1 ; i<=cols; i++) {
       
        Tc tc = Context.getWmlObjectFactory().createTc();
View Full Code Here

TOP

Related Classes of org.docx4j.wml.Tbl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.