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

Free Support Forum - aspose.com

Preserve mixed cell formatting during putvalue

Hi guys, we have a requirement where we have text in a cell that we read from a template.xls and we want to update the cell with customer information at runtime but preserve the formatting of a cell (for example the customer name is bold and we want to string.replace the customer name from a tag).

Is there any way to get a cell value with all of its formatting so we can replace text or is there a way to update a specific cell value without losing the formatting of other characters in the cell?

thanks

Marty

Hi,


Well, I think you may try to use Cell.GetCharacters() method to get the FontSettings[] (array).
e.g
Worksheet xlSheet = workbook.Worksheets[0];
FontSetting[] fontSettings = xlSheet.Cells[r, c].GetCharacters();
//Use your own code here.

Also, we provide Cell.HtmlString set/get property that you might use for your needs.

See a similar topic for your reference:
http://www.aspose.com/documentation/.net-components/aspose.cells-for-.net/formatting-selected-characters-in-a-cell.html

Thank you.

Thanks Amjad, sounds like Cell.HtmlString is the feature we should try...

Marty