Page 1 of 1

CTHeight setVal

PostPosted: Tue Sep 23, 2014 8:47 pm
by AndreasN
Hi,

I would like to set a fixed TableRow height but have no clue, how the value itself is calculated the right way?

Which "formular" is to apply to get the correct value, based on px I want to multiplicate with what factor?

private static void addTableRowHeightSetting(Tr tr, int pxFont) {

int scale = 300; // -> what is the factor here
BigInteger rowHeight = BigInteger.valueOf(pxFont * scale);
TrPr trPr = new TrPr();
CTHeight ctHeight = new CTHeight();
ctHeight.setHRule(STHeightRule.EXACT);
ctHeight.setVal(rowHeight);
JAXBElement<CTHeight> jaxbElement = wmlObjectFactory.createCTTrPrBaseTrHeight(ctHeight);
trPr.getCnfStyleOrDivIdOrGridBefore().add(jaxbElement);
tr.setTrPr(trPr);
}

Kind regards,
Andreas

Re: CTHeight setVal

PostPosted: Tue Sep 23, 2014 10:46 pm
by jason
The value is in twips (twentieths of a point). Try:

int twip = UnitsOfMeasurement.pxToTwip(pxFont);

Re: CTHeight setVal

PostPosted: Tue Sep 23, 2014 11:20 pm
by AndreasN
Great, it works!
THX!

Cheers,
Andreas