How do I get rows to auto expand to show wrapped text?

I have set cell values with some text and set their style to wrap but unfortunately the cells retain their default row height and do not automatically expand to show all the wrapped text.

How do I accomplish this?

I tried doing setUseDefaultHeight(false) on the rows but that did not change anything.

Example in Excel:

Open new Excel document

Go to random cell and type in some long text like "This is some text that should be wrapped"

Right click on cell and format cell and then check on Wrap Text

Excel automatically expands the row height to fit

Using Aspose it does not

Hi,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Please see the following sample code regarding Text wrapping feature.

//Create Workbook Object

Workbook wb = new Workbook();

//Open first Worksheet in the workbook

Worksheet ws = wb.getWorksheets().getSheet(0);

//Get Worksheet Cells Collection

Cells cell = ws.getCells();

//Increase the width of First Column Width

cell.setColumnWidth(0, 35);

//Add Text to the First Cell

cell.getCell(0, 0).setValue("I am using the latest version of Aspose.Cells to test this functionality");

//Get Cell's Style

Style style = cell.getCell(0, 0).getStyle();

//Set Text Wrap property to true

style.setTextWrapped(true);

//Set Cell's Style

cell.getCell(0, 0).setStyle(style);

//Save Excel File

wb.save("D:\\WrappingText.xls", FileFormatType.EXCEL97TO2003);

If you still face any issue, please share your complete sample code. We will check it soon.

Thank You & Best Regards,

Hi,

Also, for the issue, another notable thing for you: If the standard
height of the worksheet has been set, the height of row will be set to the
standard height when we initialize a new row and the row’s auto-fit property will
be false. For such rows, to get the auto-fit effect, you need to call
row.setUseDefaultHeight(true) manually.

e.g

Workbook workbook = new Workbook();
Worksheet worksheet = workbook.getWorksheets().getSheet(0);
Cells cells = worksheet.getCells();
cells.setStandardHeightPixels(10);
Row row = cells.getRow(0);
row.setUseDefaultHeight(true);
Cell cell = row.getCell(0);
cell.setValue(“a\nb\nc\nd\ne\nf\ng\n”);
Style style = cell.getStyle();
style.setTextWrapped(true);
cell.setStyle(style);
workbook.save(“res.xls”);


Thank you.