Free Support Forum - aspose.com

Wrap Text on Range

Hi -

I have created a named range and then merged that range. I want to set the IsTextWrap of this merged range to True. However the code I am using is throwing a null exception error. (see my code below) Does the range have to have text in it to set the wrapped text property?

Thank you!

Dim errorRange as Range = worksheet.Cells.CreateRange(21,120,5,20)

errorRange.Merge()

errorRange.Style.IsTextWrapped = True

Hi,

Thanks for considering Aspose.

Kindly utilize the following sample code to wrap the text of a merged range of cells:

Dim workbook As Workbook = New Workbook()

Dim worksheet As Worksheet = workbook.Worksheets(0)

Dim errorRange As Range = worksheet.Cells.CreateRange(21, 120, 5, 20)

errorRange.Merge()

Dim style As Style = workbook.Styles(workbook.Styles.Add)

style.IsTextWrapped = True

errorRange.Style = style

workbook.Save("d:\rtextwrapped.xls")

Regards

Amjad Sahi

Aspose Nanjing Team