We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Adjusting Row Height Makes Cells Purple!

Laurence,

This is an interesting one. It looks like if I do the following with certain templates, the cell’s background color changes to purple:

’ Create a text-wrapping style to handle autofit row height.
mexlTemplate.Styles.Add()
mexlTemplate.Styles(0).IsTextWrapped = True
exlCell.Style = mexlTemplate.Styles(0)

If I do the following, then everything works but the memory usage isn’t optimized:

’ Create a text-wrapping style to handle autofit row height.
exlCell.Style.IsTextWrapped = True

Looks like the first index of the Style object array is being overwritten by some other style. I’ve attached my project so you can recreate the issue.

Thanks,
Natan

What happens if you change your code to:

' Create a text-wrapping style to handle autofit row height.

Dim styleIndex as Integer
styleIndex = mexlTemplate.Styles.Add()
mexlTemplate.Styles(styleIndex).IsTextWrapped = True
exlCell.Style = mexlTemplate.Styles(styleIndex)

Laurence,

That was a clever idea and it almost worked. If you modify my code and run the project, you’ll see that the cell’s background is no longer purple but the cell borders are gone. Everything looks good if you were to change the last line of code to:

exlCell.Style.IsTextWrapped = True

Thanks,
Natan

Hi Natan,

When you use:

exlCell.Style = styleObject

to assign a Style object to different cells, previous setting in those cells will be overwritten. This is not a bug, but a must.

To solve your problem:

1. Use code:

exlCell.Style.IsTextWrapped = True

It's the easiest way but may consume more memory.

2. Create several Style objects and set borders or other formattings as your wish then assign them to corresponding cells. Please check the source code in our northwind demos.