Skip to content

jx:autoRowHeight

jx:autoRowHeight adjusts the row height after content is written to fit wrapped text. Without this, rows with long text content may appear truncated.

jx:autoRowHeight(lastCell="C1")
AttributeDescriptionRequired
lastCellBottom-right cell of the command areaYes

Use it when your template cells have word wrap enabled and the data may contain text of varying lengths. Without auto-fitting, Excel uses the row height from the template, which may be too short for longer content.

Template cell A1 comment:

jx:autoRowHeight(lastCell="C1")

After XLFill writes the cell content, it recalculates the row height so all wrapped text is visible.

Combine with jx:each to auto-fit every generated row:

Cell A1 comment:
jx:area(lastCell="C1")
jx:each(items="items" var="e" lastCell="C1")
Cell A1 also has:
jx:autoRowHeight(lastCell="C1")

Each row gets its height adjusted based on its content.


That’s every command in XLFill. You now know the full template language. For most reports, you’ll use jx:area + jx:each and occasionally jx:if. The rest are there when you need them.

  • Cells need “wrap text” enabled in the template. Without it, long text spills horizontally and the row stays one line tall — auto-height has nothing to expand.
  • Excel auto-fit isn’t deterministic across viewers. LibreOffice and Google Sheets may render different heights for the same value. Test in the target viewer if it matters.
  • Doesn’t shrink rows that were tall in the template. Like jx:autoColWidth, the template height is the floor.
  • Streaming mode silently no-ops. StreamWriter doesn’t let xlfill change row heights after writing. Use sequential mode if you need auto-fit on huge data.

Download the runnable example: template t17.xlsx | output 17_autorowheight.xlsx | code snippet

Learn how formulas in your templates are automatically expanded when rows are inserted:

Formulas →