Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Excel Export – Row Height Expands Despite Auto-Fit Column Width (Word Wrap Behavior)

    Hi Team,

    We are encountering an issue with Excel export in SmartGWT 13.1 EE where row heights are expanding unexpectedly, even though the column widths are already auto-expanded to fit the content.

    Observed Behavior
    • Column widths are correctly auto-expanded based on the longest value in the column (this works as expected).
    • However, for certain rows, the row height increases unnecessarily, while the cell content is still displayed on a single line.
    • This occurs even though:
      • There are no explicit line breaks (\n, <br>, etc.) in the data.
      • The content is a single continuous string (for example, an address field).
    • Notably, this behavior appears to be triggered by very small differences in content length:
      • Removing even a single character (e.g., changing "USA" to "US") causes the row height to return to normal.

    Analysis
    Based on our understanding, this seems to stem from Excel’s rendering behavior:
    • Even after auto-fitting the column width, if the rendered text slightly exceeds Excel’s internal pixel boundary, Excel pushes part of the text to the next line.
    • This results in an increased row height, even when text wrapping is not explicitly enabled.

    Expected Behavior
    Since the column width is already expanded to fully accommodate the content:
    • Word wrapping should not occur.
    • Row height should remain consistent (single line per row).
    • The uneven expansion of row heights creates a poor user experience for customers.

    Questions
    1. Is there a supported way to completely disable word wrapping in Excel exports?
    2. Can the export logic ensure one of the following:
      • Slightly increased column-width padding, or
      • Strict single-line rendering that prevents row height expansion?
    3. Are there any recommended export settings or attributes to avoid this behavior?

    Environment
    • SmartGWT Version: 13.1 EE
    • Export Format: XLS
    • We have already tried setting exportWrapCells=false, but it does not appear to have any effect.
    A screenshot is attached for reference.

    Thanks in advance for your help!
    Click image for larger version

Name:	image.png
Views:	33
Size:	254.7 KB
ID:	277355

    #2
    Hi Priyanka,

    This turned out to be an Excel bug: when you allow cell wrapping, Excel auto-fit sometimes makes subpixel errors, and assumes wrapping is necessary when it is not.

    As a workaround, we've added a new property, exportWrapCells (boolean, default true), available on ListGrid and as a
    request property on exportData() / exportClientData(). Set it to false to disable cell wrapping in the
    exported spreadsheet:

    // SmartGWT
    grid.setExportWrapCells(false);

    // SmartClient
    grid.exportClientData({ exportAs: "xls", exportWrapCells: false });

    With wrapping disabled, row heights stay at the single-line default regardless of content length. The
    tradeoff is that cells with content genuinely wider than the column will overflow rather than wrap —
    standard Excel behavior for non-wrapped cells.

    This fix will be in the next nightly build for 13.1, 14.1, and 15.0 (MAIN). See the
    ListGrid.exportWrapCells entry in the SmartClient Reference for full documentation.

    Note that if you want a deeper workaround - some way of retaining cell wrapping while not triggering the Excel bug - we could look into that. Maybe there is some way of hacking things so avoid Excel's sub-pixel rounding error bugs.

    Comment


      #3
      Thanks for the response. This is helpful, and we’re looking forward to testing the scenario in the upcoming release patch.

      Comment


        #4
        Could we get a patch fix on top of 13.0?

        Comment


          #5
          We actually added a second approach here: ListGrid.exportColumnWidthPadding / export.columnWidthPadding server property

          This adds extra character-widths to every column in the export, compensating for the sub-pixel rounding
          discrepancy between Excel's column auto-fit calculation and its text rendering engine. A value of 1 (one
          extra character-width) is generally sufficient to prevent the unwanted row height expansion while
          keeping wrapping enabled.

          The server property export.columnWidthPadding defaults to 1 starting with the next nightly build on MAIN
          (future 15.0). On 14.1 and 13.1, the server default is unset (no padding) — add
          export.columnWidthPadding: 1 to your server.properties to enable it, or set it per-export via
          ListGrid.exportColumnWidthPadding: 1.

          Most users will find that padding of 1 resolves the issue with no other code changes. You should not
          need to disable wrapping.

          Available in the next nightly build for 15.0 (MAIN), 14.1, and 13.1.

          Sorry, we can't backport as far as 13.0. But you'll get it as soon as you upgrade!

          Comment

          Working...
          X