Can I force a cell's text to wrap

I would like to programatically set the text in a column to wrap. I came across a worksheet method called

AutoFitRow().

This does not produce the desired result. I have a description field in the datatable I am binding to the Excel Spreadsheet which can be quite long. I would like to set this field to a predetermined size and then wrap the text. After looking through the API, Wiki and searching with Google I came up short of an obvious solution.

Please let me know if this is possible.

Thanks,

Tyler

Hi Tyler,

Thanks for considering Aspose.

Well you may use Style.IsTextWrapped property for wrapping text.

Here is the simple sample code which wraps text in F11 cell:

Workbook wb = new Workbook();

wb.Open(@"d:\testwrap.xls");

Worksheet sheet = wb.Worksheets[0];

// Set the width of the column F

sheet.Cells.SetColumnWidth(5,20);

Style style = sheet.Cells["F11"].Style;

style.IsTextWrapped = true;

wb.Save("d:\\testwrap1.xls");

Regards

Amjad Sahi

Aspose Nanjing Team

Would you please tell me if it is possible to apply style.IsTextWrapped = true to all cells in a column. I would like the text in a description column to wrap.

Thanks,

Tyler

Hi,

Yes,of course.

Please try Column.ApplyStyle() method.