The webapp (linked in the menu above) is your friend.
Here's what it generated for me when I uploaded a docx with a coloured header row ... the colour is a table cell property ..
Using java Syntax Highlighting
import java.math.BigInteger;
import org.docx4j.wml.CTShd;
import org.docx4j.wml.P;
import org.docx4j.wml.TblWidth;
import org.docx4j.wml.Tc;
import org.docx4j.wml.TcPr;
public class Foo
{
public JAXBElement createIt
() {
org.
docx4j.
wml.
ObjectFactory wmlObjectFactory
= new org.
docx4j.
wml.
ObjectFactory();
Tc tc
= wmlObjectFactory.
createTc();
JAXBElement
<org.
docx4j.
wml.
Tc> tcWrapped
= wmlObjectFactory.
createCTSdtContentCellTc(tc
);
// Create object for tcPr
TcPr tcpr
= wmlObjectFactory.
createTcPr();
tc.
setTcPr(tcpr
);
// Create object for tcW
TblWidth tblwidth
= wmlObjectFactory.
createTblWidth();
tcpr.
setTcW(tblwidth
);
tblwidth.
setType( "dxa");
tblwidth.
setW( BigInteger.
valueOf( 4788
) );
// Create object for shd
CTShd shd
= wmlObjectFactory.
createCTShd();
tcpr.
setShd(shd
);
shd.
setVal(org.
docx4j.
wml.
STShd.
CLEAR);
shd.
setColor( "auto");
shd.
setFill( "FFFF00");
// Create object for p
P p
= wmlObjectFactory.
createP();
tc.
getContent().
add( p
);
return tcWrapped
;
}
}
Parsed in 0.016 seconds, using
GeSHi 1.0.8.4
I'll leave it as an exercise for you to adapt the method so you pass in the tc and the color.