Page 1 of 1

how to set table border color in docx4j

PostPosted: Wed Feb 05, 2014 12:20 am
by rrr
in docx 4j the following code is for table border color :

Code: Select all
        Tbl table = factory.createTbl();
          table.setTblPr(new TblPr());
          CTBorder border = new CTBorder();
          [u]border.setColor("maroon");[/u]
          border.setSz(new BigInteger("10"));
          border.setSpace(new BigInteger("0"));
          border.setVal(STBorder.SINGLE);

          TblBorders borders = new TblBorders();
          borders.setBottom(border);
          borders.setLeft(border);
          borders.setRight(border);
          borders.setTop(border);
          borders.setInsideH(border);
          borders.setInsideV(border);





but i want how to set the table border color, please provide solution,
thanks in advance..

Re: how to set table border color in docx4j

PostPosted: Fri Feb 07, 2014 9:01 am
by jason
Sample XML:

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
                <w:tbl>
                    <w:tblPr>
                        <w:tblStyle w:val="TableGrid"/>
                        <w:tblW w:w="0" w:type="auto"/>
                        <w:tblBorders>
                            <w:top w:val="single" w:color="92D050" w:sz="4" w:space="0"/>
                            <w:left w:val="single" w:color="92D050" w:sz="4" w:space="0"/>
                            <w:bottom w:val="single" w:color="92D050" w:sz="4" w:space="0"/>
                            <w:right w:val="single" w:color="92D050" w:sz="4" w:space="0"/>
                            <w:insideH w:val="single" w:color="92D050" w:sz="4" w:space="0"/>
                            <w:insideV w:val="single" w:color="92D050" w:sz="4" w:space="0"/>
                        </w:tblBorders>
 
Parsed in 0.002 seconds, using GeSHi 1.0.8.4


Sample code, courtesy of the webapp:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
       border.setColor( "92D050");
 
Parsed in 0.013 seconds, using GeSHi 1.0.8.4

Re: how to set table border color in docx4j

PostPosted: Fri Feb 07, 2014 4:25 pm
by rrr
can we write the code in java class, instead of writing in xml
like following
Code: Select all
Tbl table = factory.createTbl();  //createtable
         table.setTblPr(new TblPr());

       CTBorder border = new CTBorder();
         border.setColor("orange");
          border.setSz(new BigInteger("10"));
          border.setSpace(new BigInteger("0"));
          border.setVal(STBorder.SINGLE);


here we write the code for border for table, likewise can we write for header of table, please provide solution..

Re: how to set table border color in docx4j

PostPosted: Fri Feb 07, 2014 7:33 pm
by jason
Use the webapp (linked in the menu above) to generate the code from a sample docx