I have fixed width of column and need autofit row height with apache POI, but I can't find working desicion for it. I tried this decision, but it doesn't work with this text
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua
Column width is 33.00 (236 pixels) and cell in table with wrap text property. I can change row height only if content height more that existing height of row.
So, I would like to ask if there is any method or desicions for autosize the row height by content?
private float calculateRowLinesForText(Font cellFont, float columnWidthInPoints, String value) {
java.awt.Font currFont = new java.awt.Font(cellFont.getFontName(), 0, cellFont.getFontHeightInPoints());
FontRenderContext frc = new FontRenderContext(null, true, true);
int lineCnt = 0;
for (String partValue : value.split("\n")) {
AttributedString attrStr = new AttributedString(partValue);
attrStr.addAttribute(TextAttribute.FONT, currFont);
LineBreakMeasurer measurer = new LineBreakMeasurer(attrStr.getIterator(), frc);
while (measurer.getPosition() < partValue.length()) {
int nextPos = measurer.nextOffset(columnWidthInPoints);
lineCnt++;
measurer.setPosition(nextPos);
}
}
return lineCnt;
}