How to set banded columns/rows using docx4j
Posted: Sat Mar 30, 2013 3:20 am
Hi,
I am creating a word document using docx4j within which I have several tables.
I would like to set table design/style for each table as well as setting the options such as "header row" "first column" etc.
I have the following:
I tried this to set the tableLook:
I see two solutions:
1) Finding out how CTShortHexNumber tblLook can be set correctly
2) or finding out how to "push" <w:tblLook w:val="04A0" w:firstRow="1" w:lastRow="0" w:firstColumn="1" w:lastColumn="0" w:noHBand="0" w:noVBand="1"/> this into the tblPr
Thanks for any help, I couldn't find anything on this subject somwhere else.
I am creating a word document using docx4j within which I have several tables.
I would like to set table design/style for each table as well as setting the options such as "header row" "first column" etc.
I have the following:
- Code: Select all
Tbl table = factory.createTbl();
// here adding content to the table ...
TblPr tblPr = factory.createTblPr();
TblPr tblPr = factory.createTblPr();
TblStyle tblStyle = factory.createCTTblPrBaseTblStyle();
tblStyle.setVal("LightGrid");
tblPr.setTblStyle(tblStyle);
// somewhere here I would like to set the column values an so on.
// something that looks like this in wml:
// <w:tblLook w:val=\"04A0\" w:firstRow=\"1\" w:lastRow=\"0\" w:firstColumn=\"1\" w:lastColumn=\"0\" w:noHBand=\"0\" w:noVBand=\"1\"/>
table.setTblPr(tblPr);
wordMLPackage.getMainDocumentPart().addObject(table);
I tried this to set the tableLook:
- Code: Select all
CTShortHexNumber tblLook = factory.createCTShortHexNumber()
// ?? don't know what to do here
tblPr.setTblLook(tblLook);
I see two solutions:
1) Finding out how CTShortHexNumber tblLook can be set correctly
2) or finding out how to "push" <w:tblLook w:val="04A0" w:firstRow="1" w:lastRow="0" w:firstColumn="1" w:lastColumn="0" w:noHBand="0" w:noVBand="1"/> this into the tblPr
Thanks for any help, I couldn't find anything on this subject somwhere else.