Unwrap cells not working

Tried wrapping text using the following code:

range.setColumnWidth(15);
Style style = cells.getStyle();
style.setTextWrapped(true);
StyleFlag styleFlag = new StyleFlag();
styleFlag.setWrapText(true);
range.applyStyle(style, styleFlag);

which worked, but to undo this changes, to unwrap cells, I tried:

Style style = cells.getStyle();
style.setTextWrapped(false);
StyleFlag styleFlag = new StyleFlag();
styleFlag.setWrapText(false);
range.applyStyle(style, styleFlag);

which doesn’t seem to work. could you please let me know as to how to unwrap cells?

@deaspose,

There is an issue with your code segment. To set wrapping text off, you need to specify setWrapText(true). Please change the line of code:
i.e.,
styleFlag.setWrapText(false);
to:
styleFlag.setWrapText(true);
it will work fine as I tested your scenario/case.

Let us know if you still find any issue.

Working fine. Thanks.

@deaspose,

Good to know that your issue resolved by the suggested line of code. Feel free to write us back if you have further comments or questions.